LibreOffice Module sd (master) 1
fubullet.cxx
Go to the documentation of this file.
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 <fubullet.hxx>
21
22#include <sfx2/bindings.hxx>
23#include <sfx2/viewfrm.hxx>
24#include <editeng/eeitem.hxx>
25#include <svl/poolitem.hxx>
26#include <editeng/fontitem.hxx>
27#include <OutlineView.hxx>
28#include <OutlineViewShell.hxx>
29#include <DrawViewShell.hxx>
30#include <ViewShellBase.hxx>
31#include <Window.hxx>
32#include <drawdoc.hxx>
33#include <strings.hrc>
34#include <sdresid.hxx>
35#include <svx/svdoutl.hxx>
36#include <sfx2/request.hxx>
37#include <svl/ctloptions.hxx>
38#include <svl/stritem.hxx>
39#include <tools/debug.hxx>
40
41#include <svx/svxdlg.hxx>
42#include <svx/svxids.hrc>
43
44namespace sd {
45
49const sal_Unicode CHAR_RLM = u'\x200F';
50const sal_Unicode CHAR_LRM = u'\x200E';
51const sal_Unicode CHAR_ZWSP = u'\x200B';
52const sal_Unicode CHAR_WJ = u'\x2060';
53const sal_Unicode CHAR_NNBSP = u'\x202F'; //NARROW NO-BREAK SPACE
54
55
57 ViewShell* pViewSh,
58 ::sd::Window* pWin,
59 ::sd::View* _pView,
60 SdDrawDocument* pDoc,
61 SfxRequest& rReq)
62 : FuPoor(pViewSh, pWin, _pView, pDoc, rReq)
63{
64}
65
67{
68 rtl::Reference<FuPoor> xFunc( new FuBullet( pViewSh, pWin, pView, pDoc, rReq ) );
69 xFunc->DoExecute(rReq);
70 return xFunc;
71}
72
74{
75 if( rReq.GetSlot() == SID_CHARMAP )
77 else
78 {
79 sal_Unicode cMark = 0;
80 switch( rReq.GetSlot() )
81 {
82 case FN_INSERT_SOFT_HYPHEN: cMark = CHAR_SOFTHYPHEN ; break;
83 case FN_INSERT_HARDHYPHEN: cMark = CHAR_HARDHYPHEN ; break;
84 case FN_INSERT_HARD_SPACE: cMark = CHAR_HARDBLANK ; break;
85 case FN_INSERT_NNBSP: cMark = CHAR_NNBSP ; break;
86 case SID_INSERT_RLM : cMark = CHAR_RLM ; break;
87 case SID_INSERT_LRM : cMark = CHAR_LRM ; break;
88 case SID_INSERT_ZWSP : cMark = CHAR_ZWSP ; break;
89 case SID_INSERT_WJ: cMark = CHAR_WJ; break;
90 }
91
92 DBG_ASSERT( cMark != 0, "FuBullet::FuBullet(), illegal slot used!" );
93
94 if( cMark )
95 InsertFormattingMark( cMark );
96 }
97
98}
99
101{
102 OutlinerView* pOV = nullptr;
103 ::Outliner* pOL = nullptr;
104
105 // depending on ViewShell set Outliner and OutlinerView
106 if( dynamic_cast< const DrawViewShell *>( mpViewShell ) != nullptr)
107 {
109 if (pOV)
111 }
112 else if( dynamic_cast< const OutlineViewShell *>( mpViewShell ) != nullptr)
113 {
114 pOL = &static_cast<OutlineView*>(mpView)->GetOutliner();
115 pOV = static_cast<OutlineView*>(mpView)->GetViewByWindow(
117 }
118
119 // insert string
120 if(!(pOV && pOL))
121 return;
122
123 // prevent flickering
124 pOV->HideCursor();
125 pOL->SetUpdateLayout(false);
126
127 // remove old selected text
128 pOV->InsertText( "" );
129
130 // prepare undo
131 SfxUndoManager& rUndoMgr = pOL->GetUndoManager();
132 rUndoMgr.EnterListAction(SdResId(STR_UNDO_INSERT_SPECCHAR),
134
135 // insert given text
136 OUString aStr( cMark );
137 pOV->InsertText( aStr, true);
138
139 ESelection aSel = pOV->GetSelection();
140 aSel.nStartPara = aSel.nEndPara;
141 aSel.nStartPos = aSel.nEndPos;
142 pOV->SetSelection(aSel);
143
144 rUndoMgr.LeaveListAction();
145
146 // restart repainting
147 pOL->SetUpdateLayout(true);
148 pOV->ShowCursor();
149}
150
152{
153 const SfxItemSet *pArgs = rReq.GetArgs();
154 const SfxStringItem* pItem = nullptr;
155 if( pArgs )
156 pItem = pArgs->GetItemIfSet(SID_CHARMAP, false);
157
158 OUString aChars;
159 vcl::Font aFont;
160 if ( pItem )
161 {
162 aChars = pItem->GetValue();
163 const SfxStringItem* pFontItem = pArgs->GetItemIfSet( SID_ATTR_SPECIALCHAR, false );
164 if ( pFontItem )
165 {
166 const OUString& aFontName = pFontItem->GetValue();
167 aFont = vcl::Font( aFontName, Size(1,1) );
168 }
169 else
170 {
171 SfxItemSet aFontAttr( mpDoc->GetPool() );
172 mpView->GetAttributes( aFontAttr );
173 const SvxFontItem* pFItem = aFontAttr.GetItem( SID_ATTR_CHAR_FONT );
174 if( pFItem )
175 aFont = vcl::Font( pFItem->GetFamilyName(), pFItem->GetStyleName(), Size( 1, 1 ) );
176 }
177 }
178
179 if (aChars.isEmpty())
180 {
181 SfxAllItemSet aSet( mpDoc->GetPool() );
182 aSet.Put( SfxBoolItem( FN_PARAM_1, false ) );
183
184 SfxItemSet aFontAttr( mpDoc->GetPool() );
185 mpView->GetAttributes( aFontAttr );
186 const SvxFontItem* pFontItem = aFontAttr.GetItem( SID_ATTR_CHAR_FONT );
187 if( pFontItem )
188 aSet.Put( *pFontItem );
189
193 xFrame) );
194
195 // If a character is selected, it can be shown
196 // pDLg->SetFont( );
197 // pDlg->SetChar( );
198 pDlg->Execute();
199 return;
200 }
201
202 if (aChars.isEmpty())
203 return;
204
205 OutlinerView* pOV = nullptr;
206 ::Outliner* pOL = nullptr;
207
208 // determine depending on ViewShell Outliner and OutlinerView
209 if(dynamic_cast< const DrawViewShell *>( mpViewShell ))
210 {
212 if (pOV)
213 {
215 }
216 }
217 else if(dynamic_cast< const OutlineViewShell *>( mpViewShell ))
218 {
219 pOL = &static_cast<OutlineView*>(mpView)->GetOutliner();
220 pOV = static_cast<OutlineView*>(mpView)->GetViewByWindow(
222 }
223
224 // insert special character
225 if (!pOV)
226 return;
227
228 // prevent flicker
229 pOV->HideCursor();
230 pOL->SetUpdateLayout(false);
231
232 /* remember old attributes:
233 To do that, remove selected area before (it has to go anyway).
234 With that, we get unique attributes (and since there is no
235 DeleteSelected() in OutlinerView, it is deleted by inserting an
236 empty string). */
237 pOV->InsertText( "" );
238
240 aOldSet.Put( pOV->GetAttribs() );
241
242 SfxUndoManager& rUndoMgr = pOL->GetUndoManager();
244 rUndoMgr.EnterListAction(SdResId(STR_UNDO_INSERT_SPECCHAR),
245 "", 0, nViewShellId );
246 pOV->InsertText(aChars, true);
247
248 // set attributes (set font)
249 SfxItemSet aSet(pOL->GetEmptyItemSet());
250 SvxFontItem aFontItem (aFont.GetFamilyType(), aFont.GetFamilyName(),
251 aFont.GetStyleName(), aFont.GetPitch(),
252 aFont.GetCharSet(),
254 aSet.Put(aFontItem);
255 aFontItem.SetWhich(EE_CHAR_FONTINFO_CJK);
256 aSet.Put(aFontItem);
257 aFontItem.SetWhich(EE_CHAR_FONTINFO_CTL);
258 aSet.Put(aFontItem);
259 pOV->SetAttribs(aSet);
260
261 ESelection aSel = pOV->GetSelection();
262 aSel.nStartPara = aSel.nEndPara;
263 aSel.nStartPos = aSel.nEndPos;
264 pOV->SetSelection(aSel);
265
266 // do not go ahead with setting attributes of special characters
267 pOV->GetOutliner()->QuickSetAttribs(aOldSet, aSel);
268
269 rUndoMgr.LeaveListAction();
270
271 // show it again
272 pOL->SetUpdateLayout(true);
273 pOV->ShowCursor();
274}
275
276void FuBullet::GetSlotState( SfxItemSet& rSet, ViewShell const * pViewShell, SfxViewFrame* pViewFrame )
277{
278 if( !(SfxItemState::DEFAULT == rSet.GetItemState( SID_CHARMAP ) ||
279 SfxItemState::DEFAULT == rSet.GetItemState( SID_CHARMAP_CONTROL ) ||
280 SfxItemState::DEFAULT == rSet.GetItemState( FN_INSERT_SOFT_HYPHEN ) ||
281 SfxItemState::DEFAULT == rSet.GetItemState( FN_INSERT_HARDHYPHEN ) ||
282 SfxItemState::DEFAULT == rSet.GetItemState( FN_INSERT_HARD_SPACE ) ||
283 SfxItemState::DEFAULT == rSet.GetItemState( FN_INSERT_NNBSP ) ||
284 SfxItemState::DEFAULT == rSet.GetItemState( SID_INSERT_RLM ) ||
285 SfxItemState::DEFAULT == rSet.GetItemState( SID_INSERT_LRM ) ||
286 SfxItemState::DEFAULT == rSet.GetItemState( SID_INSERT_WJ ) ||
287 SfxItemState::DEFAULT == rSet.GetItemState( SID_INSERT_ZWSP )))
288 return;
289
290 ::sd::View* pView = pViewShell ? pViewShell->GetView() : nullptr;
291 OutlinerView* pOLV = pView ? pView->GetTextEditOutlinerView() : nullptr;
292
293 const bool bTextEdit = pOLV;
294
295 const bool bCtlEnabled = SvtCTLOptions::IsCTLFontEnabled();
296
297 if(!bTextEdit )
298 {
299 rSet.DisableItem(FN_INSERT_SOFT_HYPHEN);
300 rSet.DisableItem(FN_INSERT_HARDHYPHEN);
301 rSet.DisableItem(FN_INSERT_HARD_SPACE);
302 rSet.DisableItem(FN_INSERT_NNBSP);
303 rSet.DisableItem(SID_INSERT_WJ);
304 rSet.DisableItem(SID_INSERT_ZWSP);
305 }
306
307 if( !bTextEdit && (dynamic_cast<OutlineViewShell const *>( pViewShell ) == nullptr) )
308 {
309 rSet.DisableItem(SID_CHARMAP);
310 rSet.DisableItem(SID_CHARMAP_CONTROL);
311 }
312
313 if(!bTextEdit || !bCtlEnabled )
314 {
315 rSet.DisableItem(SID_INSERT_RLM);
316 rSet.DisableItem(SID_INSERT_LRM);
317 }
318
319 if( pViewFrame )
320 {
321 SfxBindings& rBindings = pViewFrame->GetBindings();
322
323 rBindings.SetVisibleState( SID_INSERT_RLM, bCtlEnabled );
324 rBindings.SetVisibleState( SID_INSERT_LRM, bCtlEnabled );
325 }
326}
327} // end of namespace sd
328
329/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const OUString & GetValue() const
void SetSelection(const ESelection &)
void InsertText(const OUString &rNew, bool bSelect=false)
void HideCursor(bool bDeactivate=false)
ESelection GetSelection() const
SfxItemSet GetAttribs()
Outliner * GetOutliner() const
void SetAttribs(const SfxItemSet &)
void ShowCursor(bool bGotoCursor=true, bool bActivate=false)
void QuickSetAttribs(const SfxItemSet &rSet, const ESelection &rSel)
const SfxItemSet & GetEmptyItemSet() const
bool SetUpdateLayout(bool bUpdate)
SfxUndoManager & GetUndoManager()
SAL_DLLPRIVATE SfxItemPool & GetPool()
Definition: drawdoc.hxx:237
const OutlinerView * GetTextEditOutlinerView() const
const SdrOutliner * GetTextEditOutliner() const
void SetVisibleState(sal_uInt16 nId, bool bShow)
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void DisableItem(sal_uInt16 nWhich)
sal_uInt16 GetSlot() const
const SfxItemSet * GetArgs() const
SfxViewFrame * GetFrame() const
size_t LeaveListAction()
virtual void EnterListAction(const OUString &rComment, const OUString &rRepeatComment, sal_uInt16 nId, ViewShellId nViewShellId)
SfxBindings & GetBindings()
SfxFrame & GetFrame() const
ViewShellId GetViewShellId() const override
static bool IsCTLFontEnabled()
virtual VclPtr< SfxAbstractDialog > CreateCharMapDialog(weld::Window *pParent, const SfxItemSet &rAttr, const css::uno::Reference< css::frame::XFrame > &rFrame)=0
static SvxAbstractDialogFactory * Create()
const OUString & GetStyleName() const
const OUString & GetFamilyName() const
Base class of the stacked shells that provide graphical views to Draw and Impress documents and editi...
static rtl::Reference< FuPoor > Create(ViewShell *pViewSh, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq)
Definition: fubullet.cxx:66
virtual void DoExecute(SfxRequest &rReq) override
Definition: fubullet.cxx:73
void InsertFormattingMark(sal_Unicode cMark)
Definition: fubullet.cxx:100
void InsertSpecialCharacter(SfxRequest const &rReq)
Definition: fubullet.cxx:151
static void GetSlotState(SfxItemSet &rSet, ViewShell const *pViewShell, SfxViewFrame *pViewFrame)
Definition: fubullet.cxx:276
FuBullet(ViewShell *pViewSh, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq)
Definition: fubullet.cxx:56
Base class for all functions.
Definition: fupoor.hxx:48
SdDrawDocument * mpDoc
Definition: fupoor.hxx:148
ViewShell * mpViewShell
Definition: fupoor.hxx:145
::sd::View * mpView
Definition: fupoor.hxx:144
Show a textual overview of the text contents of all slides.
Derivative of sd::View for the outline mode |* .
Definition: OutlineView.hxx:55
Base class of the stacked shell hierarchy.
Definition: ViewShell.hxx:92
::sd::Window * GetActiveWindow() const
The active window is usually the mpContentWindow.
Definition: ViewShell.hxx:155
::sd::View * GetView() const
Definition: ViewShell.hxx:144
SD_DLLPUBLIC weld::Window * GetFrameWeld() const
Definition: viewshel.cxx:1582
SD_DLLPUBLIC ViewShellBase & GetViewShellBase() const
Definition: viewshel.cxx:1397
virtual void GetAttributes(SfxItemSet &rTargetSet, bool bOnlyHardAttr=false) const
Definition: sdview.cxx:515
ViewShell * GetViewShell() const
Definition: View.hxx:144
An SdWindow contains the actual working area of ViewShell.
Definition: Window.hxx:45
FontFamily GetFamilyType()
const OUString & GetStyleName() const
const OUString & GetFamilyName() const
FontPitch GetPitch()
rtl_TextEncoding GetCharSet() const
#define DBG_ASSERT(sCon, aError)
float u
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO_CJK(EE_CHAR_START+17)
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO_CTL(EE_CHAR_START+18)
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO(EE_CHAR_START+1)
aStr
const sal_Unicode CHAR_WJ
Definition: fubullet.cxx:52
const sal_Unicode CHAR_HARDBLANK
Definition: fubullet.cxx:46
const sal_Unicode CHAR_HARDHYPHEN
Definition: fubullet.cxx:47
const sal_Unicode CHAR_SOFTHYPHEN
Definition: fubullet.cxx:48
const sal_Unicode CHAR_LRM
Definition: fubullet.cxx:50
const sal_Unicode CHAR_RLM
Definition: fubullet.cxx:49
const sal_Unicode CHAR_ZWSP
Definition: fubullet.cxx:51
const sal_Unicode CHAR_NNBSP
Definition: fubullet.cxx:53
OUString SdResId(TranslateId aId)
Definition: sdmod.cxx:83
static SfxItemSet & rSet
sal_Int32 nStartPara
sal_Int32 nEndPos
sal_Int32 nStartPos
sal_Int32 nEndPara
Reference< XFrame > xFrame
sal_uInt16 sal_Unicode