Coverage Report

Created: 2026-11-06 11:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sd/source/ui/func/futhes.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
#include <futhes.hxx>
21
22
#include <editeng/outliner.hxx>
23
#include <sfx2/request.hxx>
24
#include <svx/ehdl.hxx>
25
#include <svx/svdobj.hxx>
26
#include <svx/svdotext.hxx>
27
#include <editeng/eeitem.hxx>
28
#include <tools/debug.hxx>
29
30
#include <svx/svxerr.hxx>
31
#include <svx/dialmgr.hxx>
32
#include <editeng/unolingu.hxx>
33
#include <vcl/weld/Window.hxx>
34
35
#include <drawdoc.hxx>
36
#include <View.hxx>
37
#include <Outliner.hxx>
38
#include <DrawViewShell.hxx>
39
#include <OutlineViewShell.hxx>
40
#include <Window.hxx>
41
42
using namespace ::com::sun::star;
43
using namespace ::com::sun::star::uno;
44
using namespace ::com::sun::star::lang;
45
using namespace ::com::sun::star::linguistic2;
46
47
class SfxRequest;
48
49
namespace sd {
50
51
52
FuThesaurus::FuThesaurus( ViewShell& rViewSh, ::sd::Window* pWin, ::sd::View* pView,
53
                  SdDrawDocument& rDoc, SfxRequest& rReq )
54
0
       : FuPoor(rViewSh, pWin, pView, rDoc, rReq)
55
0
{
56
0
}
57
58
rtl::Reference<FuPoor> FuThesaurus::Create( ViewShell& rViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument& rDoc, SfxRequest& rReq )
59
0
{
60
0
    rtl::Reference<FuPoor> xFunc( new FuThesaurus( rViewSh, pWin, pView, rDoc, rReq ) );
61
0
    xFunc->DoExecute(rReq);
62
0
    return xFunc;
63
0
}
64
65
void FuThesaurus::DoExecute(SfxRequest& rReq)
66
0
{
67
0
    SvxErrorContext aContext(ERRCTX_SVX_LINGU_THESAURUS, OUString(), mpWindow->GetFrameWeld());
68
69
0
    if (dynamic_cast< DrawViewShell *>( &mrViewShell ))
70
0
    {
71
0
        SdrTextObj* pTextObj = nullptr;
72
0
        const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
73
74
0
        if ( rMarkList.GetMarkCount() != 0 )
75
0
        {
76
0
            if ( rMarkList.GetMarkCount() == 1 )
77
0
            {
78
0
                SdrMark* pMark = rMarkList.GetMark(0);
79
0
                SdrObject* pObj = pMark->GetMarkedSdrObj();
80
81
0
                pTextObj = DynCastSdrTextObj( pObj );
82
0
            }
83
0
        }
84
85
0
        ::Outliner* pOutliner = mpView->GetTextEditOutliner();
86
0
        const OutlinerView* pOutlView = mpView->GetTextEditOutlinerView();
87
88
0
        if ( pTextObj && pOutliner && pOutlView )
89
0
        {
90
0
            if ( !pOutliner->GetSpeller().is() )
91
0
            {
92
0
                Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
93
0
                if ( xSpellChecker.is() )
94
0
                    pOutliner->SetSpeller( xSpellChecker );
95
96
0
                Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
97
0
                if( xHyphenator.is() )
98
0
                    pOutliner->SetHyphenator( xHyphenator );
99
100
0
                pOutliner->SetDefaultLanguage( mrDoc.GetLanguage( EE_CHAR_LANGUAGE ) );
101
0
            }
102
103
0
            EESpellState eState = const_cast<OutlinerView*>(pOutlView)->StartThesaurus(rReq.GetFrameWeld());
104
0
            DBG_ASSERT(eState != EESpellState::NoSpeller, "No SpellChecker");
105
0
        }
106
0
    }
107
0
    else if (dynamic_cast< OutlineViewShell *>( &mrViewShell ))
108
0
    {
109
0
        Outliner* pOutliner = mrDoc.GetOutliner();
110
0
        OutlinerView* pOutlView = pOutliner->GetView(0);
111
112
0
        if ( !pOutliner->GetSpeller().is() )
113
0
        {
114
0
            Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
115
0
            if ( xSpellChecker.is() )
116
0
                pOutliner->SetSpeller( xSpellChecker );
117
118
0
            Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
119
0
            if( xHyphenator.is() )
120
0
                pOutliner->SetHyphenator( xHyphenator );
121
122
0
            pOutliner->SetDefaultLanguage( mrDoc.GetLanguage( EE_CHAR_LANGUAGE ) );
123
0
        }
124
125
0
        EESpellState eState = pOutlView->StartThesaurus(rReq.GetFrameWeld());
126
0
        DBG_ASSERT(eState != EESpellState::NoSpeller, "No SpellChecker");
127
0
    }
128
0
}
129
130
} // end of namespace sd
131
132
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */