summaryrefslogtreecommitdiff
path: root/sw/source/uibase/shells/textsh.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/uibase/shells/textsh.cxx')
-rw-r--r--sw/source/uibase/shells/textsh.cxx333
1 files changed, 212 insertions, 121 deletions
diff --git a/sw/source/uibase/shells/textsh.cxx b/sw/source/uibase/shells/textsh.cxx
index 8300a91295ca..93020de3bad2 100644
--- a/sw/source/uibase/shells/textsh.cxx
+++ b/sw/source/uibase/shells/textsh.cxx
@@ -80,8 +80,6 @@
#include <SwRewriter.hxx>
#include <SwCapObjType.hxx>
-using namespace ::com::sun::star;
-
#include <svx/svxdlg.hxx>
#include <swabstdlg.hxx>
#include <IDocumentDrawModelAccess.hxx>
@@ -91,24 +89,29 @@ using namespace ::com::sun::star;
#include <com/sun/star/ui/dialogs/DialogClosedEvent.hpp>
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
#include <IDocumentUndoRedo.hxx>
+#include <formatcontentcontrol.hxx>
+
+using namespace ::com::sun::star;
SFX_IMPL_INTERFACE(SwTextShell, SwBaseShell)
IMPL_STATIC_LINK( SwTextShell, DialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, pEvent, void )
{
- SwView* pView = ::GetActiveView();
- SwWrtShell& rWrtShell = pView->GetWrtShell();
-
- sal_Int16 nDialogRet = pEvent->DialogResult;
- if( nDialogRet == ui::dialogs::ExecutableDialogResults::CANCEL )
+ if (SwView* pView = GetActiveView())
{
- rWrtShell.Undo();
- rWrtShell.GetIDocumentUndoRedo().ClearRedo();
- }
- else
- {
- OSL_ENSURE( nDialogRet == ui::dialogs::ExecutableDialogResults::OK,
- "dialog execution failed" );
+ SwWrtShell& rWrtShell = pView->GetWrtShell();
+
+ sal_Int16 nDialogRet = pEvent->DialogResult;
+ if( nDialogRet == ui::dialogs::ExecutableDialogResults::CANCEL )
+ {
+ rWrtShell.Undo();
+ rWrtShell.GetIDocumentUndoRedo().ClearRedo();
+ }
+ else
+ {
+ OSL_ENSURE( nDialogRet == ui::dialogs::ExecutableDialogResults::OK,
+ "dialog execution failed" );
+ }
}
}
@@ -164,7 +167,8 @@ void SwTextShell::ExecInsert(SfxRequest &rReq)
&& pACorr->IsAutoCorrFlag(
ACFlags::CapitalStartSentence | ACFlags::CapitalStartWord |
ACFlags::AddNonBrkSpace | ACFlags::ChgOrdinalNumber | ACFlags::TransliterateRTL |
- ACFlags::ChgToEnEmDash | ACFlags::SetINetAttr | ACFlags::Autocorrect ) )
+ ACFlags::ChgToEnEmDash | ACFlags::SetINetAttr | ACFlags::Autocorrect |
+ ACFlags::SetDOIAttr ) )
{
rSh.AutoCorrect( *pACorr, cIns );
}
@@ -196,7 +200,7 @@ void SwTextShell::ExecInsert(SfxRequest &rReq)
case FN_INSERT_BREAK:
{
- if( !rSh.CursorInsideInputField() )
+ if (!rSh.CursorInsideInputField() && !rSh.CursorInsideContentControl())
{
rSh.SplitNode();
}
@@ -218,6 +222,53 @@ void SwTextShell::ExecInsert(SfxRequest &rReq)
rReq.Done();
break;
+ case FN_INSERT_CONTENT_CONTROL:
+ rSh.InsertContentControl(SwContentControlType::RICH_TEXT);
+ rReq.Done();
+ break;
+
+ case FN_INSERT_CHECKBOX_CONTENT_CONTROL:
+ rSh.InsertContentControl(SwContentControlType::CHECKBOX);
+ rReq.Done();
+ break;
+
+ case FN_INSERT_DROPDOWN_CONTENT_CONTROL:
+ rSh.InsertContentControl(SwContentControlType::DROP_DOWN_LIST);
+ rReq.Done();
+ break;
+
+ case FN_INSERT_PICTURE_CONTENT_CONTROL:
+ rSh.InsertContentControl(SwContentControlType::PICTURE);
+ rReq.Done();
+ break;
+
+ case FN_INSERT_DATE_CONTENT_CONTROL:
+ rSh.InsertContentControl(SwContentControlType::DATE);
+ rReq.Done();
+ break;
+
+ case FN_INSERT_PLAIN_TEXT_CONTENT_CONTROL:
+ rSh.InsertContentControl(SwContentControlType::PLAIN_TEXT);
+ rReq.Done();
+ break;
+
+ case FN_INSERT_COMBO_BOX_CONTENT_CONTROL:
+ rSh.InsertContentControl(SwContentControlType::COMBO_BOX);
+ rReq.Done();
+ break;
+
+ case FN_CONTENT_CONTROL_PROPERTIES:
+ {
+ SwWrtShell& rWrtSh = GetShell();
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateSwContentControlDlg(GetView().GetFrameWeld(), rWrtSh));
+ VclAbstractDialog::AsyncContext aContext;
+ aContext.maEndDialogFn = [](sal_Int32){};
+ pDlg->StartExecuteAsync(aContext);
+ rReq.Done();
+ break;
+ }
+
case FN_INSERT_COLUMN_BREAK:
rSh.InsertColumnBreak();
rReq.Done();
@@ -266,7 +317,7 @@ void SwTextShell::ExecInsert(SfxRequest &rReq)
OUString aName;
xObj.Assign( aCnt.CreateEmbeddedObject( SvGlobalName( SO3_IFRAME_CLASSID ).GetByteSequence(), aName ),
embed::Aspects::MSOLE_CONTENT );
- svt::EmbeddedObjectRef::TryRunningState( xObj.GetObject() );
+ (void)svt::EmbeddedObjectRef::TryRunningState( xObj.GetObject() );
uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
if ( xSet.is() )
{
@@ -280,28 +331,28 @@ void SwTextShell::ExecInsert(SfxRequest &rReq)
if ( pMarginItem )
aMargin = pMarginItem->GetSize();
- xSet->setPropertyValue("FrameURL", uno::makeAny( pURLItem->GetValue() ) );
+ xSet->setPropertyValue("FrameURL", uno::Any( pURLItem->GetValue() ) );
if ( pNameItem )
- xSet->setPropertyValue("FrameName", uno::makeAny( pNameItem->GetValue() ) );
+ xSet->setPropertyValue("FrameName", uno::Any( pNameItem->GetValue() ) );
if ( eScroll == ScrollingMode::Auto )
xSet->setPropertyValue("FrameIsAutoScroll",
- uno::makeAny( true ) );
+ uno::Any( true ) );
else
xSet->setPropertyValue("FrameIsScrollingMode",
- uno::makeAny( eScroll == ScrollingMode::Yes ) );
+ uno::Any( eScroll == ScrollingMode::Yes ) );
if ( pBorderItem )
xSet->setPropertyValue("FrameIsBorder",
- uno::makeAny( pBorderItem->GetValue() ) );
+ uno::Any( pBorderItem->GetValue() ) );
if ( pMarginItem )
{
xSet->setPropertyValue("FrameMarginWidth",
- uno::makeAny( sal_Int32( aMargin.Width() ) ) );
+ uno::Any( sal_Int32( aMargin.Width() ) ) );
xSet->setPropertyValue("FrameMarginHeight",
- uno::makeAny( sal_Int32( aMargin.Height() ) ) );
+ uno::Any( sal_Int32( aMargin.Height() ) ) );
}
}
catch (const uno::Exception&)
@@ -351,8 +402,7 @@ void SwTextShell::ExecInsert(SfxRequest &rReq)
if(pItem && xObj.is())
{
Size aSize(static_cast<const SvxSizeItem*>(pItem)->GetSize());
- aSize = OutputDevice::LogicToLogic
- ( aSize, MapMode( MapUnit::MapTwip ), MapMode( MapUnit::Map100thMM ) );
+ aSize = o3tl::convert(aSize, o3tl::Length::twip, o3tl::Length::mm100);
if(aSize.Width() > MINLAY&& aSize.Height()> MINLAY)
{
@@ -387,11 +437,12 @@ void SwTextShell::ExecInsert(SfxRequest &rReq)
bool bModifier1 = rReq.GetModifier() == KEY_MOD1;
if(pArgs)
{
+ const SfxUInt16Item* pColsItem = nullptr;
if(FN_INSERT_FRAME_INTERACT_NOCOL != nSlot &&
- pArgs->GetItemState(SID_ATTR_COLUMNS, false, &pItem) == SfxItemState::SET)
- nCols = static_cast<const SfxUInt16Item *>(pItem)->GetValue();
- if(pArgs->GetItemState(SID_MODIFIER, false, &pItem) == SfxItemState::SET)
- bModifier1 |= KEY_MOD1 == static_cast<const SfxUInt16Item *>(pItem)->GetValue();
+ (pColsItem = pArgs->GetItemIfSet(SID_ATTR_COLUMNS, false)))
+ nCols = pColsItem->GetValue();
+ if(const SfxUInt16Item* pModifierItem = pArgs->GetItemIfSet(SID_MODIFIER, false))
+ bModifier1 |= KEY_MOD1 == pModifierItem->GetValue();
}
if(bModifier1 )
{
@@ -399,10 +450,12 @@ void SwTextShell::ExecInsert(SfxRequest &rReq)
Size aWinSize = rEdtWin.GetSizePixel();
Point aStartPos(aWinSize.Width()/2, aWinSize.Height() / 2);
aStartPos = rEdtWin.PixelToLogic(aStartPos);
- aStartPos.AdjustX( -(8 * MM50) );
- aStartPos.AdjustY( -(4 * MM50) );
- Size aSize(16 * MM50, 8 * MM50);
- GetShell().LockPaint();
+ constexpr tools::Long constTwips_2cm = o3tl::toTwips(2, o3tl::Length::cm);
+ constexpr tools::Long constTwips_4cm = o3tl::toTwips(4, o3tl::Length::cm);
+ aStartPos.AdjustX(-constTwips_4cm);
+ aStartPos.AdjustY(-constTwips_2cm);
+ Size aSize(2 * constTwips_4cm, 2 * constTwips_2cm);
+ GetShell().LockPaint(LockPaintReason::InsertFrame);
GetShell().StartAllAction();
SwFlyFrameAttrMgr aMgr( true, GetShellPtr(), Frmmgr_Type::TEXT, nullptr );
if(nCols > 1)
@@ -427,8 +480,7 @@ void SwTextShell::ExecInsert(SfxRequest &rReq)
bool bSingleCol = false;
if( nullptr!= dynamic_cast< SwWebDocShell*>( GetView().GetDocShell()) )
{
- SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
- if( HTML_CFG_MSIE == rHtmlOpt.GetExportMode() )
+ if( HTML_CFG_MSIE == SvxHtmlOptions::GetExportMode() )
{
bSingleCol = true;
}
@@ -448,9 +500,9 @@ void SwTextShell::ExecInsert(SfxRequest &rReq)
aPos = static_cast<const SfxPointItem *>(pItem)->GetValue();
if(pArgs->GetItemState(FN_PARAM_2, false, &pItem) == SfxItemState::SET)
aSize = static_cast<const SvxSizeItem *>(pItem)->GetSize();
- if(pArgs->GetItemState(SID_ATTR_COLUMNS, false, &pItem) == SfxItemState::SET)
+ if(const SfxUInt16Item* pColsItem = pArgs->GetItemIfSet(SID_ATTR_COLUMNS, false))
{
- const sal_uInt16 nCols = static_cast<const SfxUInt16Item *>(pItem)->GetValue();
+ const sal_uInt16 nCols = pColsItem->GetValue();
if( !bSingleCol && 1 < nCols )
{
SwFormatCol aFormatCol;
@@ -460,7 +512,7 @@ void SwTextShell::ExecInsert(SfxRequest &rReq)
}
}
- GetShell().LockPaint();
+ GetShell().LockPaint(LockPaintReason::InsertFrame);
GetShell().StartAllAction();
aMgr.InsertFlyFrame(eAnchor, aPos, aSize);
@@ -475,51 +527,65 @@ void SwTextShell::ExecInsert(SfxRequest &rReq)
FieldUnit eMetric = ::GetDfltMetric(dynamic_cast<SwWebDocShell*>( GetView().GetDocShell()) != nullptr );
SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
- ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateFrameTabDialog("FrameDialog",
+ VclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateFrameTabDialog("FrameDialog",
GetView().GetViewFrame(),
GetView().GetFrameWeld(),
aSet));
- if(pDlg->Execute() == RET_OK && pDlg->GetOutputItemSet())
- {
- //local variable necessary at least after call of .AutoCaption() because this could be deleted at this point
- SwWrtShell& rShell = GetShell();
- rShell.LockPaint();
- rShell.StartAllAction();
- rShell.StartUndo(SwUndoId::INSERT);
-
- const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
- aMgr.SetAttrSet(*pOutSet);
+ pDlg->StartExecuteAsync([aSet, pDlg, nSlot, this](sal_Int32 nResult) {
+ if (nResult == RET_OK && pDlg->GetOutputItemSet())
+ {
+ SwFlyFrameAttrMgr aAttrMgr( true, GetShellPtr(), Frmmgr_Type::TEXT, nullptr );
+ //local variable necessary at least after call of .AutoCaption() because this could be deleted at this point
+ SwWrtShell& rShell = GetShell();
+ rShell.LockPaint(LockPaintReason::InsertFrame);
+ rShell.StartAllAction();
+ rShell.StartUndo(SwUndoId::INSERT);
+
+ SfxItemSet aOutSet(*pDlg->GetOutputItemSet());
+ const SvxBoxItem* pBox = aSet.GetItem(RES_BOX);
+ if (pBox && !aOutSet.HasItem(RES_BOX))
+ {
+ // The input set had border info but the output set not, then copy it over
+ // to not lose the custom border info. This can happen when a whole table
+ // is selected and that case has its own defaults, not matching the frame
+ // style.
+ aOutSet.Put(*pBox);
+ }
+ aAttrMgr.SetAttrSet(aOutSet);
- // At first delete the selection at the ClickToEditField.
- if( rShell.IsInClickToEdit() )
- rShell.DelRight();
+ // At first delete the selection at the ClickToEditField.
+ if( rShell.IsInClickToEdit() )
+ rShell.DelRight();
- aMgr.InsertFlyFrame();
+ aAttrMgr.InsertFlyFrame();
- uno::Reference< frame::XDispatchRecorder > xRecorder =
- GetView().GetViewFrame()->GetBindings().GetRecorder();
- if ( xRecorder.is() )
- {
- //FN_INSERT_FRAME
- sal_uInt16 nAnchor = static_cast<sal_uInt16>(aMgr.GetAnchor());
- rReq.AppendItem(SfxUInt16Item(nSlot, nAnchor));
- rReq.AppendItem(SfxPointItem(FN_PARAM_1, rShell.GetObjAbsPos()));
- rReq.AppendItem(SvxSizeItem(FN_PARAM_2, rShell.GetObjSize()));
- rReq.Done();
- }
+ uno::Reference< frame::XDispatchRecorder > xRecorder =
+ GetView().GetViewFrame().GetBindings().GetRecorder();
+ if ( xRecorder.is() )
+ {
+ //FN_INSERT_FRAME
+ sal_uInt16 nAnchor = static_cast<sal_uInt16>(aAttrMgr.GetAnchor());
+ SfxRequest aReq(GetView().GetViewFrame(), FN_INSERT_FRAME);
+ aReq.AppendItem(SfxUInt16Item(nSlot, nAnchor));
+ aReq.AppendItem(SfxPointItem(FN_PARAM_1, rShell.GetObjAbsPos()));
+ aReq.AppendItem(SvxSizeItem(FN_PARAM_2, rShell.GetObjSize()));
+ aReq.Done();
+ }
- GetView().AutoCaption(FRAME_CAP);
+ GetView().AutoCaption(FRAME_CAP);
- {
- SwRewriter aRewriter;
+ {
+ SwRewriter aRewriter;
- aRewriter.AddRule(UndoArg1, SwResId(STR_FRAME));
+ aRewriter.AddRule(UndoArg1, SwResId(STR_FRAME));
- rShell.EndUndo(SwUndoId::INSERT, &aRewriter);
+ rShell.EndUndo(SwUndoId::INSERT, &aRewriter);
+ }
+ rShell.EndAllAction();
+ rShell.UnlockPaint();
}
- rShell.EndAllAction();
- rShell.UnlockPaint();
- }
+ pDlg->disposeOnce();
+ });
}
break;
}
@@ -556,14 +622,7 @@ void SwTextShell::StateInsert( SfxItemSet &rSet )
SvtModuleOptions aMOpt;
SfxObjectCreateMode eCreateMode =
GetView().GetDocShell()->GetCreateMode();
-
- bool bCursorInHidden = false;
- if( !rSh.HasMark() )
- {
- rSh.Push();
- bCursorInHidden = rSh.SelectHiddenRange();
- rSh.Pop();
- }
+ const bool bCursorInHidden = rSh.IsInHiddenRange(/*bSelect=*/false);
while ( nWhich )
{
@@ -613,8 +672,7 @@ void SwTextShell::StateInsert( SfxItemSet &rSet )
}
else if(SID_INSERT_FLOATINGFRAME == nWhich && bHtmlModeOn)
{
- SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
- const sal_uInt16 nExport = rHtmlOpt.GetExportMode();
+ const sal_uInt16 nExport = SvxHtmlOptions::GetExportMode();
if(HTML_CFG_MSIE != nExport && HTML_CFG_WRITER != nExport )
rSet.DisableItem(nWhich);
}
@@ -634,14 +692,12 @@ void SwTextShell::StateInsert( SfxItemSet &rSet )
case SID_HYPERLINK_GETLINK:
{
- SfxItemSet aSet(GetPool(), svl::Items<RES_TXTATR_INETFMT, RES_TXTATR_INETFMT>{});
+ SfxItemSetFixed<RES_TXTATR_INETFMT, RES_TXTATR_INETFMT> aSet(GetPool());
rSh.GetCurAttr( aSet );
SvxHyperlinkItem aHLinkItem;
- const SfxPoolItem* pItem;
- if(SfxItemState::SET == aSet.GetItemState(RES_TXTATR_INETFMT, false, &pItem))
+ if(const SwFormatINetFormat* pINetFormat = aSet.GetItemIfSet(RES_TXTATR_INETFMT, false))
{
- const SwFormatINetFormat* pINetFormat = static_cast<const SwFormatINetFormat*>(pItem);
aHLinkItem.SetURL(pINetFormat->GetValue());
aHLinkItem.SetTargetFrame(pINetFormat->GetTargetFrame());
aHLinkItem.SetIntName(pINetFormat->GetName());
@@ -821,7 +877,36 @@ void SwTextShell::ExecTransliteration( SfxRequest const & rReq )
void SwTextShell::ExecRotateTransliteration( SfxRequest const & rReq )
{
if( rReq.GetSlot() == SID_TRANSLITERATE_ROTATE_CASE )
- GetShell().TransliterateText( m_aRotateCase.getNextMode() );
+ {
+ TransliterationFlags transFlags = m_aRotateCase.getNextMode();
+ bool bSentenceCase = TransliterationFlags::SENTENCE_CASE == transFlags;
+ SwWrtShell& rSh = GetShell();
+ if (rSh.HasSelection())
+ {
+ if (bSentenceCase)
+ {
+ OUString aSelection = rSh.GetSelText().trim();
+ if (aSelection.getLength() <= 2 || (aSelection.indexOf(' ') < 0 && aSelection.indexOf('\t') < 0))
+ transFlags = m_aRotateCase.getNextMode();
+ }
+ rSh.TransliterateText(transFlags);
+ }
+ else
+ {
+ if (bSentenceCase)
+ {
+ if (!rSh.IsEndSentence())
+ rSh.EndSentence(false);
+ }
+ if (rSh.IsEndSentence())
+ {
+ rSh.BwdSentence(true);
+ rSh.TransliterateText(transFlags);
+ }
+ else if ((rSh.IsEndWrd() || rSh.IsStartWord() || rSh.IsInWord()) && rSh.SelWrd())
+ rSh.TransliterateText(transFlags);
+ }
+ }
}
SwTextShell::SwTextShell(SwView &_rView) :
@@ -837,20 +922,15 @@ SwTextShell::~SwTextShell()
SfxItemSet SwTextShell::CreateInsertFrameItemSet(SwFlyFrameAttrMgr& rMgr)
{
- static const sal_uInt16 aFrameAttrRange[] =
- {
+ SfxItemSet aSet(GetPool(), svl::Items<
RES_FRMATR_BEGIN, RES_FRMATR_END-1,
+ XATTR_FILL_FIRST, XATTR_FILL_LAST, // tdf#95003
SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
- FN_GET_PRINT_AREA, FN_GET_PRINT_AREA,
SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
- FN_SET_FRM_NAME, FN_SET_FRM_NAME,
- SID_HTML_MODE, SID_HTML_MODE,
SID_COLOR_TABLE, SID_PATTERN_LIST,
- XATTR_FILL_FIRST, XATTR_FILL_LAST, // tdf#95003
- 0
- };
-
- SfxItemSet aSet(GetPool(), aFrameAttrRange );
+ SID_HTML_MODE, SID_HTML_MODE,
+ FN_GET_PRINT_AREA, FN_GET_PRINT_AREA,
+ FN_SET_FRM_NAME, FN_SET_FRM_NAME>);
aSet.Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(GetView().GetDocShell())));
// For the Area tab page.
@@ -858,12 +938,12 @@ SfxItemSet SwTextShell::CreateInsertFrameItemSet(SwFlyFrameAttrMgr& rMgr)
const SwRect &rPg = GetShell().GetAnyCurRect(CurRectType::Page);
SwFormatFrameSize aFrameSize(SwFrameSize::Variable, rPg.Width(), rPg.Height());
- aFrameSize.SetWhich(GetPool().GetWhich(SID_ATTR_PAGE_SIZE));
+ aFrameSize.SetWhich(GetPool().GetWhichIDFromSlotID(SID_ATTR_PAGE_SIZE));
aSet.Put(aFrameSize);
const SwRect &rPr = GetShell().GetAnyCurRect(CurRectType::PagePrt);
SwFormatFrameSize aPrtSize(SwFrameSize::Variable, rPr.Width(), rPr.Height());
- aPrtSize.SetWhich(GetPool().GetWhich(FN_GET_PRINT_AREA));
+ aPrtSize.SetWhich(GetPool().GetWhichIDFromSlotID(FN_GET_PRINT_AREA));
aSet.Put(aPrtSize);
aSet.Put(rMgr.GetAttrSet());
@@ -876,31 +956,35 @@ SfxItemSet SwTextShell::CreateInsertFrameItemSet(SwFlyFrameAttrMgr& rMgr)
aBoxInfo.SetDefDist(rBox.GetDistance(SvxBoxItemLine::LEFT));
aSet.Put(aBoxInfo);
+ if (!SwFlyFrameAttrMgr::SingleTableSelected(GetShell()))
+ {
+ SwFormatAnchor aAnchor(RndStdIds::FLY_AT_CHAR);
+ aSet.Put(aAnchor);
+ }
+
return aSet;
}
void SwTextShell::InsertSymbol( SfxRequest& rReq )
{
const SfxItemSet *pArgs = rReq.GetArgs();
- const SfxPoolItem* pItem = nullptr;
+ const SfxStringItem* pItem = nullptr;
if( pArgs )
- pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), false, &pItem);
+ pItem = pArgs->GetItemIfSet(SID_CHARMAP, false);
OUString aChars, aFontName;
if ( pItem )
{
- aChars = static_cast<const SfxStringItem*>(pItem)->GetValue();
- const SfxPoolItem* pFtItem = nullptr;
- pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), false, &pFtItem);
- const SfxStringItem* pFontItem = dynamic_cast<const SfxStringItem*>( pFtItem );
+ aChars = pItem->GetValue();
+ const SfxStringItem* pFontItem = pArgs->GetItemIfSet( SID_ATTR_SPECIALCHAR, false );
if ( pFontItem )
aFontName = pFontItem->GetValue();
}
SwWrtShell &rSh = GetShell();
- SfxItemSet aSet( GetPool(), svl::Items<RES_CHRATR_FONT, RES_CHRATR_FONT,
- RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_FONT,
- RES_CHRATR_CTL_FONT, RES_CHRATR_CTL_FONT>{} );
+ SfxItemSetFixed<RES_CHRATR_FONT, RES_CHRATR_FONT,
+ RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_FONT,
+ RES_CHRATR_CTL_FONT, RES_CHRATR_CTL_FONT> aSet( GetPool() );
rSh.GetCurAttr( aSet );
SvtScriptType nScript = rSh.GetScriptType();
@@ -915,11 +999,11 @@ void SwTextShell::InsertSymbol( SfxRequest& rReq )
}
else
{
- aFont.reset(static_cast<SvxFontItem*>(
- aSet.Get(
+ TypedWhichId<SvxFontItem> nFontWhich =
GetWhichOfScript(
RES_CHRATR_FONT,
- SvtLanguageOptions::GetI18NScriptTypeOfLanguage( GetAppLanguage() ) )).Clone()));
+ SvtLanguageOptions::GetI18NScriptTypeOfLanguage( GetAppLanguage() ) );
+ aFont.reset(aSet.Get(nFontWhich).Clone());
}
if (aFontName.isEmpty())
@@ -941,9 +1025,14 @@ void SwTextShell::InsertSymbol( SfxRequest& rReq )
aAllSet.Put( SfxStringItem( SID_FONT_NAME, aFont->GetFamilyName() ) );
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
- auto xFrame = GetView().GetViewFrame()->GetFrame().GetFrameInterface();
- ScopedVclPtr<SfxAbstractDialog> pDlg(pFact->CreateCharMapDialog(GetView().GetFrameWeld(), aAllSet, xFrame));
- pDlg->Execute();
+ auto xFrame = GetView().GetViewFrame().GetFrame().GetFrameInterface();
+ VclPtr<SfxAbstractDialog> pDlg(pFact->CreateCharMapDialog(GetView().GetFrameWeld(), aAllSet, xFrame));
+ pDlg->StartExecuteAsync(
+ [pDlg] (sal_Int32 /*nResult*/)->void
+ {
+ pDlg->disposeOnce();
+ }
+ );
return;
}
@@ -972,9 +1061,11 @@ void SwTextShell::InsertSymbol( SfxRequest& rReq )
}
else
{
- aFont.reset(static_cast<SvxFontItem*>(aSet.Get( GetWhichOfScript(
+ TypedWhichId<SvxFontItem> nFontWhich =
+ GetWhichOfScript(
RES_CHRATR_FONT,
- SvtLanguageOptions::GetI18NScriptTypeOfLanguage( GetAppLanguage() ) )).Clone()));
+ SvtLanguageOptions::GetI18NScriptTypeOfLanguage( GetAppLanguage() ) );
+ aFont.reset(aSet.Get( nFontWhich ).Clone());
}
}
@@ -990,9 +1081,9 @@ void SwTextShell::InsertSymbol( SfxRequest& rReq )
aNewFontItem->SetPitch( aNewFont.GetPitch());
aNewFontItem->SetCharSet( aNewFont.GetCharSet() );
- SfxItemSet aRestoreSet( GetPool(), svl::Items<RES_CHRATR_FONT, RES_CHRATR_FONT,
- RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_FONT,
- RES_CHRATR_CTL_FONT, RES_CHRATR_CTL_FONT>{} );
+ SfxItemSetFixed<RES_CHRATR_FONT, RES_CHRATR_FONT,
+ RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_FONT,
+ RES_CHRATR_CTL_FONT, RES_CHRATR_CTL_FONT> aRestoreSet( GetPool() );
nScript = g_pBreakIt->GetAllScriptsOfText( aChars );
if( SvtScriptType::LATIN & nScript )
@@ -1041,7 +1132,7 @@ void SwTextShell::InsertSymbol( SfxRequest& rReq )
if ( !aChars.isEmpty() )
{
- rReq.AppendItem( SfxStringItem( GetPool().GetWhich(SID_CHARMAP), aChars ) );
+ rReq.AppendItem( SfxStringItem( SID_CHARMAP, aChars ) );
rReq.AppendItem( SfxStringItem( SID_ATTR_SPECIALCHAR, aNewFont.GetFamilyName() ) );
rReq.Done();
}