Coverage Report

Created: 2025-12-08 09:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/linguistic/source/lngprophelp.cxx
Line
Count
Source
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
21
#include <tools/debug.hxx>
22
#include <sal/log.hxx>
23
24
#include <com/sun/star/linguistic2/LinguServiceEvent.hpp>
25
#include <com/sun/star/linguistic2/LinguServiceEventFlags.hpp>
26
#include <com/sun/star/linguistic2/XLinguServiceEventListener.hpp>
27
#include <com/sun/star/linguistic2/XLinguProperties.hpp>
28
#include <com/sun/star/beans/XPropertySet.hpp>
29
#include <osl/mutex.hxx>
30
#include <unotools/linguprops.hxx>
31
32
#include <linguistic/misc.hxx>
33
#include <linguistic/lngprops.hxx>
34
35
#include <linguistic/lngprophelp.hxx>
36
37
using namespace osl;
38
using namespace com::sun::star;
39
using namespace com::sun::star::beans;
40
using namespace com::sun::star::lang;
41
using namespace com::sun::star::uno;
42
using namespace com::sun::star::linguistic2;
43
using namespace linguistic;
44
45
46
namespace linguistic
47
{
48
49
50
PropertyChgHelper::PropertyChgHelper(
51
        const Reference< XInterface > &rxSource,
52
        Reference< XLinguProperties > const &rxPropSet,
53
        int nAllowedEvents ) :
54
0
    aPropNames          ({UPN_IS_IGNORE_CONTROL_CHARACTERS, UPN_IS_USE_DICTIONARY_LIST}),
55
0
    xMyEvtObj           (rxSource),
56
0
    aLngSvcEvtListeners (GetLinguMutex()),
57
0
    xPropSet            (rxPropSet),
58
0
    nEvtFlags           (nAllowedEvents)
59
0
{
60
0
    SetDefaultValues();
61
0
}
62
63
PropertyChgHelper::~PropertyChgHelper()
64
0
{
65
0
}
66
67
void PropertyChgHelper::SetDefaultValues()
68
0
{
69
0
    bResIsIgnoreControlCharacters   = bIsIgnoreControlCharacters    = true;
70
0
    bResIsUseDictionaryList         = bIsUseDictionaryList          = true;
71
0
}
72
73
74
void PropertyChgHelper::GetCurrentValues()
75
0
{
76
0
    const auto& rPropNames = GetPropNames();
77
0
    if (!GetPropSet().is() || rPropNames.empty())
78
0
        return;
79
80
0
    for (const OUString& rPropName : rPropNames)
81
0
    {
82
0
        bool *pbVal     = nullptr,
83
0
             *pbResVal  = nullptr;
84
85
0
        if ( rPropName == UPN_IS_IGNORE_CONTROL_CHARACTERS )
86
0
        {
87
0
            pbVal    = &bIsIgnoreControlCharacters;
88
0
            pbResVal = &bResIsIgnoreControlCharacters;
89
0
        }
90
0
        else if ( rPropName == UPN_IS_USE_DICTIONARY_LIST )
91
0
        {
92
0
            pbVal    = &bIsUseDictionaryList;
93
0
            pbResVal = &bResIsUseDictionaryList;
94
0
        }
95
96
0
        if (pbVal && pbResVal)
97
0
        {
98
0
            GetPropSet()->getPropertyValue( rPropName ) >>= *pbVal;
99
0
            *pbResVal = *pbVal;
100
0
        }
101
0
    }
102
0
}
103
104
105
void PropertyChgHelper::SetTmpPropVals( const PropertyValues &rPropVals )
106
0
{
107
    // return value is default value unless there is an explicitly supplied
108
    // temporary value
109
0
    bResIsIgnoreControlCharacters   = bIsIgnoreControlCharacters;
110
0
    bResIsUseDictionaryList         = bIsUseDictionaryList;
111
112
0
    for (const PropertyValue& rVal : rPropVals)
113
0
    {
114
0
        bool  *pbResVal = nullptr;
115
0
        switch (rVal.Handle)
116
0
        {
117
0
            case UPH_IS_IGNORE_CONTROL_CHARACTERS :
118
0
                    pbResVal = &bResIsIgnoreControlCharacters; break;
119
0
            case UPH_IS_USE_DICTIONARY_LIST     :
120
0
                    pbResVal = &bResIsUseDictionaryList; break;
121
0
            default:
122
0
                    ;
123
0
        }
124
0
        if (pbResVal)
125
0
            rVal.Value >>= *pbResVal;
126
0
    }
127
0
}
128
129
130
bool PropertyChgHelper::propertyChange_Impl( const PropertyChangeEvent& rEvt )
131
0
{
132
0
    bool bRes = false;
133
134
0
    if (GetPropSet().is()  &&  rEvt.Source == GetPropSet())
135
0
    {
136
0
        sal_Int16 nLngSvcFlags = (nEvtFlags & AE_HYPHENATOR) ?
137
0
                    LinguServiceEventFlags::HYPHENATE_AGAIN : 0;
138
0
        bool bSCWA = false, // SPELL_CORRECT_WORDS_AGAIN ?
139
0
             bSWWA = false; // SPELL_WRONG_WORDS_AGAIN ?
140
141
0
        bool  *pbVal = nullptr;
142
0
        switch (rEvt.PropertyHandle)
143
0
        {
144
0
            case UPH_IS_IGNORE_CONTROL_CHARACTERS :
145
0
            {
146
0
                pbVal = &bIsIgnoreControlCharacters;
147
0
                nLngSvcFlags = 0;
148
0
                break;
149
0
            }
150
0
            case UPH_IS_USE_DICTIONARY_LIST       :
151
0
            {
152
0
                pbVal = &bIsUseDictionaryList;
153
0
                bSCWA = bSWWA = true;
154
0
                break;
155
0
            }
156
0
        }
157
0
        if (pbVal)
158
0
            rEvt.NewValue >>= *pbVal;
159
160
0
        bRes = nullptr != pbVal;  // sth changed?
161
0
        if (bRes)
162
0
        {
163
0
            bool bSpellEvts = (nEvtFlags & AE_SPELLCHECKER);
164
0
            if (bSCWA && bSpellEvts)
165
0
                nLngSvcFlags |= LinguServiceEventFlags::SPELL_CORRECT_WORDS_AGAIN;
166
0
            if (bSWWA && bSpellEvts)
167
0
                nLngSvcFlags |= LinguServiceEventFlags::SPELL_WRONG_WORDS_AGAIN;
168
0
            if (nLngSvcFlags)
169
0
            {
170
0
                LinguServiceEvent aEvt( GetEvtObj(), nLngSvcFlags );
171
0
                LaunchEvent( aEvt );
172
0
            }
173
0
        }
174
0
    }
175
176
0
    return bRes;
177
0
}
178
179
180
void SAL_CALL
181
    PropertyChgHelper::propertyChange( const PropertyChangeEvent& rEvt )
182
0
{
183
0
    MutexGuard  aGuard( GetLinguMutex() );
184
0
    propertyChange_Impl( rEvt );
185
0
}
186
187
188
void PropertyChgHelper::AddAsPropListener()
189
0
{
190
0
    if (xPropSet.is())
191
0
    {
192
0
        for (const OUString& rPropName : aPropNames)
193
0
        {
194
0
            if (!rPropName.isEmpty())
195
0
                xPropSet->addPropertyChangeListener( rPropName, this );
196
0
        }
197
0
    }
198
0
}
199
200
void PropertyChgHelper::RemoveAsPropListener()
201
0
{
202
0
    if (xPropSet.is())
203
0
    {
204
0
        for (const OUString& rPropName : aPropNames)
205
0
        {
206
0
            if (!rPropName.isEmpty())
207
0
                xPropSet->removePropertyChangeListener( rPropName, this );
208
0
        }
209
0
    }
210
0
}
211
212
213
void PropertyChgHelper::LaunchEvent( const LinguServiceEvent &rEvt )
214
0
{
215
0
    aLngSvcEvtListeners.notifyEach( &XLinguServiceEventListener::processLinguServiceEvent, rEvt );
216
0
}
217
218
219
void SAL_CALL PropertyChgHelper::disposing( const EventObject& rSource )
220
0
{
221
0
    MutexGuard  aGuard( GetLinguMutex() );
222
0
    if (rSource.Source == xPropSet)
223
0
    {
224
0
        RemoveAsPropListener();
225
0
        xPropSet = nullptr;
226
0
        aPropNames.clear();
227
0
    }
228
0
}
229
230
231
sal_Bool SAL_CALL
232
    PropertyChgHelper::addLinguServiceEventListener(
233
            const Reference< XLinguServiceEventListener >& rxListener )
234
0
{
235
0
    MutexGuard  aGuard( GetLinguMutex() );
236
237
0
    bool bRes = false;
238
0
    if (rxListener.is())
239
0
    {
240
0
        sal_Int32   nCount = aLngSvcEvtListeners.getLength();
241
0
        bRes = aLngSvcEvtListeners.addInterface( rxListener ) != nCount;
242
0
    }
243
0
    return bRes;
244
0
}
245
246
247
sal_Bool SAL_CALL
248
    PropertyChgHelper::removeLinguServiceEventListener(
249
            const Reference< XLinguServiceEventListener >& rxListener )
250
0
{
251
0
    MutexGuard  aGuard( GetLinguMutex() );
252
253
0
    bool bRes = false;
254
0
    if (rxListener.is())
255
0
    {
256
0
        sal_Int32   nCount = aLngSvcEvtListeners.getLength();
257
0
        bRes = aLngSvcEvtListeners.removeInterface( rxListener ) != nCount;
258
0
    }
259
0
    return bRes;
260
0
}
261
262
263
PropertyHelper_Thes::PropertyHelper_Thes(
264
        const Reference< XInterface > &rxSource,
265
        Reference< XLinguProperties > const &rxPropSet ) :
266
0
    PropertyChgHelper   ( rxSource, rxPropSet, 0 )
267
0
{
268
0
    SetDefaultValues();
269
0
    GetCurrentValues();
270
0
}
271
272
273
PropertyHelper_Thes::~PropertyHelper_Thes()
274
{
275
}
276
277
278
void SAL_CALL
279
    PropertyHelper_Thes::propertyChange( const PropertyChangeEvent& rEvt )
280
0
{
281
0
    MutexGuard  aGuard( GetLinguMutex() );
282
0
    PropertyChgHelper::propertyChange_Impl( rEvt );
283
0
}
284
285
286
PropertyHelper_Spell::PropertyHelper_Spell(
287
        const Reference< XInterface > & rxSource,
288
        Reference< XLinguProperties > const &rxPropSet ) :
289
0
    PropertyChgHelper   ( rxSource, rxPropSet, AE_SPELLCHECKER )
290
0
{
291
0
    auto& rPropNames = GetPropNames();
292
0
    rPropNames.push_back(UPN_IS_SPELL_UPPER_CASE);
293
0
    rPropNames.push_back(UPN_IS_SPELL_WITH_DIGITS);
294
0
    rPropNames.push_back(UPN_IS_SPELL_CLOSED_COMPOUND);
295
0
    rPropNames.push_back(UPN_IS_SPELL_HYPHENATED_COMPOUND);
296
0
    SetDefaultValues();
297
0
    GetCurrentValues();
298
0
}
299
300
301
PropertyHelper_Spell::~PropertyHelper_Spell()
302
{
303
}
304
305
306
void PropertyHelper_Spell::SetDefaultValues()
307
0
{
308
0
    PropertyChgHelper::SetDefaultValues();
309
310
0
    bResIsSpellUpperCase        = bIsSpellUpperCase         = false;
311
0
    bResIsSpellWithDigits       = bIsSpellWithDigits        = false;
312
0
    bResIsSpellClosedCompound   = bIsSpellClosedCompound    = true;
313
0
    bResIsSpellHyphenatedCompound = bIsSpellHyphenatedCompound = true;
314
0
}
315
316
317
void PropertyHelper_Spell::GetCurrentValues()
318
0
{
319
0
    PropertyChgHelper::GetCurrentValues();
320
321
0
    const auto& rPropNames = GetPropNames();
322
0
    if (!GetPropSet().is() || rPropNames.empty())
323
0
        return;
324
325
0
    for (const OUString& rPropName : rPropNames)
326
0
    {
327
0
        bool *pbVal     = nullptr,
328
0
             *pbResVal  = nullptr;
329
330
0
        if ( rPropName == UPN_IS_SPELL_UPPER_CASE )
331
0
        {
332
0
            pbVal    = &bIsSpellUpperCase;
333
0
            pbResVal = &bResIsSpellUpperCase;
334
0
        }
335
0
        else if ( rPropName == UPN_IS_SPELL_WITH_DIGITS )
336
0
        {
337
0
            pbVal    = &bIsSpellWithDigits;
338
0
            pbResVal = &bResIsSpellWithDigits;
339
0
        }
340
0
        else if ( rPropName == UPN_IS_SPELL_CLOSED_COMPOUND )
341
0
        {
342
0
            pbVal    = &bIsSpellClosedCompound;
343
0
            pbResVal = &bResIsSpellClosedCompound;
344
0
        }
345
0
        else if ( rPropName == UPN_IS_SPELL_HYPHENATED_COMPOUND )
346
0
        {
347
0
            pbVal    = &bIsSpellHyphenatedCompound;
348
0
            pbResVal = &bResIsSpellHyphenatedCompound;
349
0
        }
350
351
0
        if (pbVal && pbResVal)
352
0
        {
353
0
            GetPropSet()->getPropertyValue( rPropName ) >>= *pbVal;
354
0
            *pbResVal = *pbVal;
355
0
        }
356
0
    }
357
0
}
358
359
360
bool PropertyHelper_Spell::propertyChange_Impl( const PropertyChangeEvent& rEvt )
361
0
{
362
0
    bool bRes = PropertyChgHelper::propertyChange_Impl( rEvt );
363
364
0
    if (!bRes  &&  GetPropSet().is()  &&  rEvt.Source == GetPropSet())
365
0
    {
366
0
        bool bSCWA = false, // SPELL_CORRECT_WORDS_AGAIN ?
367
0
             bSWWA = false; // SPELL_WRONG_WORDS_AGAIN ?
368
369
0
        bool *pbVal = nullptr;
370
0
        switch (rEvt.PropertyHandle)
371
0
        {
372
0
            case UPH_IS_SPELL_UPPER_CASE          :
373
0
            {
374
0
                pbVal = &bIsSpellUpperCase;
375
0
                bSCWA = ! *pbVal;    // sal_False->sal_True change?
376
0
                bSWWA = !bSCWA;             // sal_True->sal_False change?
377
0
                break;
378
0
            }
379
0
            case UPH_IS_SPELL_WITH_DIGITS         :
380
0
            {
381
0
                pbVal = &bIsSpellWithDigits;
382
0
                bSCWA = ! *pbVal;    // sal_False->sal_True change?
383
0
                bSWWA = !bSCWA;             // sal_True->sal_False change?
384
0
                break;
385
0
            }
386
0
            case UPH_IS_SPELL_CLOSED_COMPOUND     :
387
0
            {
388
0
                pbVal = &bIsSpellClosedCompound;
389
0
                bSCWA = ! *pbVal;    // sal_False->sal_True change?
390
0
                bSWWA = !bSCWA;             // sal_True->sal_False change?
391
0
                break;
392
0
            }
393
0
            case UPH_IS_SPELL_HYPHENATED_COMPOUND :
394
0
            {
395
0
                pbVal = &bIsSpellHyphenatedCompound;
396
0
                bSCWA = ! *pbVal;    // sal_False->sal_True change?
397
0
                bSWWA = !bSCWA;             // sal_True->sal_False change?
398
0
                break;
399
0
            }
400
0
            default:
401
0
                SAL_WARN( "linguistic", "unknown property handle " << rEvt.PropertyHandle << " (check in include/unotools/linguprops.hxx)" );
402
0
        }
403
0
        if (pbVal)
404
0
            rEvt.NewValue >>= *pbVal;
405
406
0
        bRes = (pbVal != nullptr);
407
0
        if (bRes)
408
0
        {
409
0
            sal_Int16 nLngSvcFlags = 0;
410
0
            if (bSCWA)
411
0
                nLngSvcFlags |= LinguServiceEventFlags::SPELL_CORRECT_WORDS_AGAIN;
412
0
            if (bSWWA)
413
0
                nLngSvcFlags |= LinguServiceEventFlags::SPELL_WRONG_WORDS_AGAIN;
414
0
            if (nLngSvcFlags)
415
0
            {
416
0
                LinguServiceEvent aEvt( GetEvtObj(), nLngSvcFlags );
417
0
                LaunchEvent( aEvt );
418
0
            }
419
0
        }
420
0
    }
421
422
0
    return bRes;
423
0
}
424
425
426
void SAL_CALL
427
    PropertyHelper_Spell::propertyChange( const PropertyChangeEvent& rEvt )
428
0
{
429
0
    MutexGuard  aGuard( GetLinguMutex() );
430
0
    propertyChange_Impl( rEvt );
431
0
}
432
433
434
void PropertyHelper_Spell::SetTmpPropVals( const PropertyValues &rPropVals )
435
0
{
436
0
    PropertyChgHelper::SetTmpPropVals( rPropVals );
437
438
    // return value is default value unless there is an explicitly supplied
439
    // temporary value
440
0
    bResIsSpellWithDigits       = bIsSpellWithDigits;
441
0
    bResIsSpellClosedCompound   = bIsSpellClosedCompound;
442
0
    bResIsSpellHyphenatedCompound = bIsSpellHyphenatedCompound;
443
0
    bResIsSpellUpperCase        = bIsSpellUpperCase;
444
445
0
    for (const PropertyValue& rVal : rPropVals)
446
0
    {
447
0
        if ( rVal.Name == UPN_MAX_NUMBER_OF_SUGGESTIONS )
448
0
        {
449
            // special value that is not part of the property set and thus needs to be handled differently
450
0
        }
451
0
        else
452
0
        {
453
0
            bool *pbResVal = nullptr;
454
0
            switch (rVal.Handle)
455
0
            {
456
0
                case UPH_IS_SPELL_UPPER_CASE     : pbResVal = &bResIsSpellUpperCase; break;
457
0
                case UPH_IS_SPELL_WITH_DIGITS    : pbResVal = &bResIsSpellWithDigits; break;
458
0
                case UPH_IS_SPELL_CLOSED_COMPOUND : pbResVal = &bResIsSpellClosedCompound; break;
459
0
                case UPH_IS_SPELL_HYPHENATED_COMPOUND : pbResVal = &bResIsSpellHyphenatedCompound; break;
460
0
                default:
461
0
                    SAL_WARN( "linguistic", "unknown property handle " << rVal.Handle << " (check in include/unotools/linguprops.hxx)" );
462
0
            }
463
0
            if (pbResVal)
464
0
                rVal.Value >>= *pbResVal;
465
0
        }
466
0
    }
467
0
}
468
469
PropertyHelper_Hyphen::PropertyHelper_Hyphen(
470
        const Reference< XInterface > & rxSource,
471
        Reference< XLinguProperties > const &rxPropSet ) :
472
0
    PropertyChgHelper   ( rxSource, rxPropSet, AE_HYPHENATOR )
473
0
{
474
0
    auto& rPropNames = GetPropNames();
475
0
    rPropNames.push_back(UPN_HYPH_MIN_LEADING);
476
0
    rPropNames.push_back(UPN_HYPH_MIN_TRAILING);
477
0
    rPropNames.push_back(UPN_HYPH_MIN_WORD_LENGTH);
478
0
    SetDefaultValues();
479
0
    GetCurrentValues();
480
0
}
481
482
483
PropertyHelper_Hyphen::~PropertyHelper_Hyphen()
484
{
485
}
486
487
488
void PropertyHelper_Hyphen::SetDefaultValues()
489
0
{
490
0
    PropertyChgHelper::SetDefaultValues();
491
492
0
    nResHyphMinLeading      = nHyphMinLeading       = 2;
493
0
    nResHyphMinTrailing     = nHyphMinTrailing      = 2;
494
0
    nResHyphCompoundMinLeading = nHyphCompoundMinLeading = 2;
495
0
    nResHyphMinWordLength   = nHyphMinWordLength    = 0;
496
0
    nResHyphTextHyphenZone  = nHyphTextHyphenZone   = 0;
497
0
    bResNoHyphenateCaps = bNoHyphenateCaps = false;
498
0
}
499
500
501
void PropertyHelper_Hyphen::GetCurrentValues()
502
0
{
503
0
    PropertyChgHelper::GetCurrentValues();
504
505
0
    const auto& rPropNames = GetPropNames();
506
0
    if (!GetPropSet().is() || rPropNames.empty())
507
0
        return;
508
509
0
    for (const OUString& rPropName : rPropNames)
510
0
    {
511
0
        sal_Int16  *pnVal    = nullptr,
512
0
               *pnResVal = nullptr;
513
0
        bool *pbVal = nullptr;
514
0
        bool *pbResVal = nullptr;
515
516
0
        if ( rPropName == UPN_HYPH_MIN_LEADING )
517
0
        {
518
0
            pnVal    = &nHyphMinLeading;
519
0
            pnResVal = &nResHyphMinLeading;
520
0
        }
521
0
        else if ( rPropName == UPN_HYPH_MIN_TRAILING )
522
0
        {
523
0
            pnVal    = &nHyphMinTrailing;
524
0
            pnResVal = &nResHyphMinTrailing;
525
0
        }
526
0
        if ( rPropName == UPN_HYPH_COMPOUND_MIN_LEADING )
527
0
        {
528
0
            pnVal    = &nHyphCompoundMinLeading;
529
0
            pnResVal = &nResHyphCompoundMinLeading;
530
0
        }
531
0
        else if ( rPropName == UPN_HYPH_MIN_WORD_LENGTH )
532
0
        {
533
0
            pnVal    = &nHyphMinWordLength;
534
0
            pnResVal = &nResHyphMinWordLength;
535
0
        }
536
0
        else if ( rPropName == UPN_HYPH_ZONE )
537
0
        {
538
0
            pnVal    = &nHyphTextHyphenZone;
539
0
            pnResVal = &nResHyphTextHyphenZone;
540
0
        }
541
0
        else if ( rPropName == UPN_HYPH_NO_CAPS )
542
0
        {
543
0
            pbVal    = &bNoHyphenateCaps;
544
0
            pbResVal = &bResNoHyphenateCaps;
545
0
        }
546
547
0
        if (pnVal && pnResVal)
548
0
        {
549
0
            GetPropSet()->getPropertyValue( rPropName ) >>= *pnVal;
550
0
            *pnResVal = *pnVal;
551
0
        }
552
0
        else if (pbVal && pbResVal)
553
0
        {
554
0
            GetPropSet()->getPropertyValue( rPropName ) >>= *pbVal;
555
0
            *pbResVal = *pbVal;
556
0
        }
557
0
    }
558
0
}
559
560
561
bool PropertyHelper_Hyphen::propertyChange_Impl( const PropertyChangeEvent& rEvt )
562
0
{
563
0
    bool bRes = PropertyChgHelper::propertyChange_Impl( rEvt );
564
565
0
    if (!bRes  &&  GetPropSet().is()  &&  rEvt.Source == GetPropSet())
566
0
    {
567
0
        sal_Int16   *pnVal = nullptr;
568
0
        bool *pbVal = nullptr;
569
0
        switch (rEvt.PropertyHandle)
570
0
        {
571
0
            case UPH_HYPH_MIN_LEADING     : pnVal = &nHyphMinLeading; break;
572
0
            case UPH_HYPH_MIN_TRAILING    : pnVal = &nHyphMinTrailing; break;
573
0
            case UPH_HYPH_COMPOUND_MIN_LEADING : pnVal = &nHyphCompoundMinLeading; break;
574
0
            case UPH_HYPH_MIN_WORD_LENGTH : pnVal = &nHyphMinWordLength; break;
575
0
            case UPH_HYPH_ZONE            : pnVal = &nHyphTextHyphenZone; break;
576
0
            case UPH_HYPH_NO_CAPS : pbVal = &bNoHyphenateCaps; break;
577
0
            default:
578
0
                SAL_WARN( "linguistic", "unknown property handle " << rEvt.PropertyHandle << " (check in include/unotools/linguprops.hxx)");
579
0
        }
580
0
        if (pnVal)
581
0
            rEvt.NewValue >>= *pnVal;
582
0
        else if (pbVal)
583
0
            rEvt.NewValue >>= *pbVal;
584
585
0
        bRes = (pnVal != nullptr || pbVal != nullptr);
586
0
        if (bRes)
587
0
        {
588
0
            LinguServiceEvent aEvt(GetEvtObj(), LinguServiceEventFlags::HYPHENATE_AGAIN);
589
0
            LaunchEvent(aEvt);
590
0
        }
591
0
    }
592
593
0
    return bRes;
594
0
}
595
596
597
void SAL_CALL
598
    PropertyHelper_Hyphen::propertyChange( const PropertyChangeEvent& rEvt )
599
0
{
600
0
    MutexGuard  aGuard( GetLinguMutex() );
601
0
    propertyChange_Impl( rEvt );
602
0
}
603
604
605
void PropertyHelper_Hyphen::SetTmpPropVals( const PropertyValues &rPropVals )
606
0
{
607
0
    PropertyChgHelper::SetTmpPropVals( rPropVals );
608
609
    // return value is default value unless there is an explicitly supplied
610
    // temporary value
611
0
    nResHyphMinLeading      = nHyphMinLeading;
612
0
    nResHyphMinTrailing     = nHyphMinTrailing;
613
0
    nResHyphCompoundMinLeading = nHyphCompoundMinLeading;
614
0
    nResHyphMinWordLength   = nHyphMinWordLength;
615
0
    nResHyphTextHyphenZone  = nHyphTextHyphenZone;
616
0
    bResNoHyphenateCaps = bNoHyphenateCaps;
617
618
0
    for (const PropertyValue& rVal : rPropVals)
619
0
    {
620
0
        sal_Int16 *pnResVal = nullptr;
621
0
        bool *pbResVal = nullptr;
622
623
0
        if ( rVal.Name == UPN_HYPH_MIN_LEADING )
624
0
            pnResVal = &nResHyphMinLeading;
625
0
        else if ( rVal.Name == UPN_HYPH_MIN_TRAILING )
626
0
            pnResVal = &nResHyphMinTrailing;
627
0
        if ( rVal.Name == UPN_HYPH_COMPOUND_MIN_LEADING )
628
0
            pnResVal = &nResHyphCompoundMinLeading;
629
0
        else if ( rVal.Name == UPN_HYPH_MIN_WORD_LENGTH )
630
0
            pnResVal = &nResHyphMinWordLength;
631
0
        else if ( rVal.Name == UPN_HYPH_ZONE )
632
0
            pnResVal = &nResHyphTextHyphenZone;
633
0
        else if ( rVal.Name == UPN_HYPH_NO_CAPS )
634
0
            pbResVal = &bResNoHyphenateCaps;
635
0
        else if (rVal.Name == UPN_HYPH_NO_LAST_WORD ||
636
0
                 rVal.Name == UPN_HYPH_KEEP ||
637
0
                 rVal.Name == UPN_HYPH_KEEP_LINE ||
638
0
                 rVal.Name == UPN_HYPH_ZONE_ALWAYS ||
639
0
                 rVal.Name == UPN_HYPH_KEEP_TYPE)
640
0
        {
641
            // skip these known ones without warnings
642
0
            continue;
643
0
        }
644
645
0
        SAL_WARN_IF( !(pnResVal || pbResVal), "linguistic", "unknown property '" << rVal.Name << "'");
646
647
0
        if (pnResVal)
648
0
            rVal.Value >>= *pnResVal;
649
0
        else if (pbResVal)
650
0
            rVal.Value >>= *pbResVal;
651
0
    }
652
0
}
653
654
PropertyHelper_Thesaurus::PropertyHelper_Thesaurus(
655
            const css::uno::Reference< css::uno::XInterface > &rxSource,
656
            css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet )
657
0
{
658
0
    mxPropHelper = new PropertyHelper_Thes( rxSource, rxPropSet );
659
0
}
660
661
PropertyHelper_Thesaurus::~PropertyHelper_Thesaurus()
662
0
{
663
0
}
664
665
void PropertyHelper_Thesaurus::AddAsPropListener()
666
0
{
667
0
    mxPropHelper->AddAsPropListener();
668
0
}
669
670
void PropertyHelper_Thesaurus::RemoveAsPropListener()
671
0
{
672
0
    mxPropHelper->RemoveAsPropListener();
673
0
}
674
675
void PropertyHelper_Thesaurus::SetTmpPropVals( const css::beans::PropertyValues &rPropVals )
676
0
{
677
0
    mxPropHelper->SetTmpPropVals( rPropVals );
678
0
}
679
680
PropertyHelper_Hyphenation::PropertyHelper_Hyphenation(
681
            const css::uno::Reference< css::uno::XInterface > &rxSource,
682
            css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet)
683
0
{
684
0
    mxPropHelper = new PropertyHelper_Hyphen( rxSource, rxPropSet );
685
0
}
686
687
PropertyHelper_Hyphenation::~PropertyHelper_Hyphenation()
688
0
{
689
0
}
690
691
void PropertyHelper_Hyphenation::AddAsPropListener()
692
0
{
693
0
    mxPropHelper->AddAsPropListener();
694
0
}
695
696
void PropertyHelper_Hyphenation::RemoveAsPropListener()
697
0
{
698
0
    mxPropHelper->RemoveAsPropListener();
699
0
}
700
701
void PropertyHelper_Hyphenation::SetTmpPropVals( const css::beans::PropertyValues &rPropVals )
702
0
{
703
0
    mxPropHelper->SetTmpPropVals( rPropVals );
704
0
}
705
706
sal_Int16 PropertyHelper_Hyphenation::GetMinLeading() const
707
0
{
708
0
    return mxPropHelper->GetMinLeading();
709
0
}
710
711
sal_Int16 PropertyHelper_Hyphenation::GetMinTrailing() const
712
0
{
713
0
    return mxPropHelper->GetMinTrailing();
714
0
}
715
716
sal_Int16 PropertyHelper_Hyphenation::GetCompoundMinLeading() const
717
0
{
718
0
    return mxPropHelper->GetCompoundMinLeading();
719
0
}
720
721
sal_Int16 PropertyHelper_Hyphenation::GetMinWordLength() const
722
0
{
723
0
    return mxPropHelper->GetMinWordLength();
724
0
}
725
726
bool PropertyHelper_Hyphenation::IsNoHyphenateCaps() const
727
0
{
728
0
    return mxPropHelper->IsNoHyphenateCaps();
729
0
}
730
731
bool PropertyHelper_Hyphenation::addLinguServiceEventListener(
732
                const css::uno::Reference< css::linguistic2::XLinguServiceEventListener >& rxListener )
733
0
{
734
0
    return mxPropHelper->addLinguServiceEventListener( rxListener );
735
0
}
736
737
bool PropertyHelper_Hyphenation::removeLinguServiceEventListener(
738
                const css::uno::Reference< css::linguistic2::XLinguServiceEventListener >& rxListener )
739
0
{
740
0
    return mxPropHelper->removeLinguServiceEventListener( rxListener );
741
0
}
742
743
PropertyHelper_Spelling::PropertyHelper_Spelling(
744
            const css::uno::Reference< css::uno::XInterface > &rxSource,
745
            css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet )
746
0
{
747
0
    mxPropHelper = new PropertyHelper_Spell( rxSource, rxPropSet );
748
0
}
749
750
PropertyHelper_Spelling::~PropertyHelper_Spelling()
751
0
{
752
0
}
753
754
void PropertyHelper_Spelling::AddAsPropListener()
755
0
{
756
0
    mxPropHelper->AddAsPropListener();
757
0
}
758
759
void PropertyHelper_Spelling::RemoveAsPropListener()
760
0
{
761
0
    mxPropHelper->RemoveAsPropListener();
762
0
}
763
764
void PropertyHelper_Spelling::SetTmpPropVals( const css::beans::PropertyValues &rPropVals )
765
0
{
766
0
    mxPropHelper->SetTmpPropVals( rPropVals );
767
0
}
768
769
bool PropertyHelper_Spelling::IsSpellUpperCase() const
770
0
{
771
0
    return mxPropHelper->IsSpellUpperCase();
772
0
}
773
774
bool PropertyHelper_Spelling::IsSpellWithDigits() const
775
0
{
776
0
    return mxPropHelper->IsSpellWithDigits();
777
0
}
778
779
bool PropertyHelper_Spelling::IsSpellClosedCompound() const
780
0
{
781
0
    return mxPropHelper->IsSpellClosedCompound();
782
0
}
783
784
bool PropertyHelper_Spelling::IsSpellHyphenatedCompound() const
785
0
{
786
0
    return mxPropHelper->IsSpellHyphenatedCompound();
787
0
}
788
789
bool PropertyHelper_Spelling::addLinguServiceEventListener(
790
                const css::uno::Reference<
791
                    css::linguistic2::XLinguServiceEventListener >& rxListener )
792
0
{
793
0
    return mxPropHelper->addLinguServiceEventListener( rxListener );
794
0
}
795
796
bool PropertyHelper_Spelling::removeLinguServiceEventListener(
797
                const css::uno::Reference<
798
                    css::linguistic2::XLinguServiceEventListener >& rxListener )
799
0
{
800
0
    return mxPropHelper->removeLinguServiceEventListener( rxListener );
801
0
}
802
803
}   // namespace linguistic
804
805
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */