Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / sd / source / ui / func / fuchar.cxx
bloba0f80d8ac365f8a4ee3d3a8529fbbb64e9843d36
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 .
20 #include <fuchar.hxx>
21 #include <svx/dialogs.hrc>
22 #include <sfx2/viewfrm.hxx>
24 #include <editeng/editdata.hxx>
25 #include <svx/svxids.hrc>
26 #include <editeng/eeitem.hxx>
27 #include <editeng/colritem.hxx>
28 #include <editeng/brushitem.hxx>
29 #include <sfx2/bindings.hxx>
30 #include <sfx2/request.hxx>
31 #include <View.hxx>
32 #include <Window.hxx>
33 #include <drawview.hxx>
34 #include <drawdoc.hxx>
35 #include <DrawViewShell.hxx>
36 #include <ViewShell.hxx>
37 #include <DrawDocShell.hxx>
38 #include <sdabstdlg.hxx>
39 #include <memory>
41 namespace sd {
44 FuChar::FuChar (
45 ViewShell* pViewSh,
46 ::sd::Window* pWin,
47 ::sd::View* pView,
48 SdDrawDocument* pDoc,
49 SfxRequest& rReq)
50 : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
54 rtl::Reference<FuPoor> FuChar::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
56 rtl::Reference<FuPoor> xFunc( new FuChar( pViewSh, pWin, pView, pDoc, rReq ) );
57 xFunc->DoExecute(rReq);
58 return xFunc;
61 void FuChar::DoExecute( SfxRequest& rReq )
63 const SfxItemSet* pArgs = rReq.GetArgs();
65 if( !pArgs )
67 SfxItemSet aEditAttr( mpDoc->GetPool() );
68 mpView->GetAttributes( aEditAttr );
70 SfxItemSet aNewAttr(mpViewShell->GetPool(), svl::Items<EE_ITEMS_START, EE_ITEMS_END>{});
71 aNewAttr.Put( aEditAttr, false );
73 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
74 ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact ? pFact->CreateSdTabCharDialog(mpViewShell->GetActiveWindow(), &aNewAttr, mpDoc->GetDocSh() ) : nullptr);
75 sal_uInt16 nResult = RET_CANCEL;
76 if( pDlg )
78 if (rReq.GetSlot() == SID_CHAR_DLG_EFFECT)
80 pDlg->SetCurPageId("RID_SVXPAGE_CHAR_EFFECTS");
83 nResult = pDlg->Execute();
85 if( nResult == RET_OK )
87 const SfxItemSet* pOutputSet = pDlg->GetOutputItemSet();
88 SfxItemSet aOtherSet( *pOutputSet );
90 // and now the reverse process
91 const SvxBrushItem* pBrushItem = aOtherSet.GetItem<SvxBrushItem>( SID_ATTR_BRUSH_CHAR );
93 if ( pBrushItem )
95 SvxBackgroundColorItem aBackColorItem( pBrushItem->GetColor(), EE_CHAR_BKGCOLOR );
96 aOtherSet.ClearItem( SID_ATTR_BRUSH_CHAR );
97 aOtherSet.Put( aBackColorItem );
100 rReq.Done( aOtherSet );
101 pArgs = rReq.GetArgs();
104 if( nResult != RET_OK )
106 return;
109 mpView->SetAttributes(*pArgs);
111 // invalidate the Slots which are in DrTxtObjBar
112 static const sal_uInt16 SidArray[] = {
113 SID_ATTR_CHAR_FONT,
114 SID_ATTR_CHAR_POSTURE,
115 SID_ATTR_CHAR_WEIGHT,
116 SID_ATTR_CHAR_SHADOWED,
117 SID_ATTR_CHAR_STRIKEOUT,
118 SID_ATTR_CHAR_UNDERLINE,
119 SID_ATTR_CHAR_FONTHEIGHT,
120 SID_ATTR_CHAR_COLOR,
121 SID_ATTR_CHAR_KERNING,
122 SID_ATTR_CHAR_CASEMAP,
123 SID_SET_SUPER_SCRIPT,
124 SID_SET_SUB_SCRIPT,
125 SID_ATTR_CHAR_BACK_COLOR,
126 0 };
128 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
130 if( mpDoc->GetOnlineSpell() )
132 const SfxPoolItem* pItem;
133 if( SfxItemState::SET == pArgs->GetItemState(EE_CHAR_LANGUAGE, false, &pItem ) ||
134 SfxItemState::SET == pArgs->GetItemState(EE_CHAR_LANGUAGE_CJK, false, &pItem ) ||
135 SfxItemState::SET == pArgs->GetItemState(EE_CHAR_LANGUAGE_CTL, false, &pItem ) )
137 mpDoc->StopOnlineSpelling();
138 mpDoc->StartOnlineSpelling();
143 void FuChar::Activate()
147 void FuChar::Deactivate()
151 } // end of namespace sd
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */