Stop leaking all ScPostIt instances.
[LibreOffice.git] / sc / source / ui / drawfunc / drtxtob1.cxx
blobfcff116d6aa3b5ec1837be4aad04349bd86278d2
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 "scitems.hxx"
21 #include <editeng/eeitem.hxx>
23 #include <svx/svxdlg.hxx>
24 #include <editeng/formatbreakitem.hxx>
25 #include <editeng/hyphenzoneitem.hxx>
26 #include <editeng/orphitem.hxx>
27 #include <editeng/outliner.hxx>
28 #include <editeng/spltitem.hxx>
29 #include <editeng/widwitem.hxx>
30 #include <sot/exchange.hxx>
31 #include <vcl/msgbox.hxx>
32 #include <svtools/transfer.hxx>
34 #include "sc.hrc"
35 #include "drtxtob.hxx"
36 #include "drawview.hxx"
37 #include "viewdata.hxx"
38 #include "scresid.hxx"
40 #include "scabstdlg.hxx"
41 //------------------------------------------------------------------------
43 sal_Bool ScDrawTextObjectBar::ExecuteCharDlg( const SfxItemSet& rArgs,
44 SfxItemSet& rOutSet , sal_uInt16 nSlot)
46 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
47 OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
49 SfxAbstractTabDialog* pDlg = pFact->CreateScCharDlg( pViewData->GetDialogParent(), &rArgs,
50 pViewData->GetSfxDocShell(),RID_SCDLG_CHAR );
51 OSL_ENSURE(pDlg, "Dialog create fail!");
52 if (nSlot == SID_CHAR_DLG_EFFECT)
54 pDlg->SetCurPageId(RID_SVXPAGE_CHAR_EFFECTS);
56 sal_Bool bRet = ( pDlg->Execute() == RET_OK );
58 if ( bRet )
60 const SfxItemSet* pNewAttrs = pDlg->GetOutputItemSet();
61 if ( pNewAttrs )
62 rOutSet.Put( *pNewAttrs );
64 delete pDlg;
66 return bRet;
69 sal_Bool ScDrawTextObjectBar::ExecuteParaDlg( const SfxItemSet& rArgs,
70 SfxItemSet& rOutSet )
72 SfxItemPool* pArgPool = rArgs.GetPool();
73 SfxItemSet aNewAttr( *pArgPool,
74 EE_ITEMS_START, EE_ITEMS_END,
75 SID_ATTR_PARA_HYPHENZONE, SID_ATTR_PARA_HYPHENZONE,
76 SID_ATTR_PARA_PAGEBREAK, SID_ATTR_PARA_PAGEBREAK,
77 SID_ATTR_PARA_SPLIT, SID_ATTR_PARA_SPLIT,
78 SID_ATTR_PARA_WIDOWS, SID_ATTR_PARA_WIDOWS,
79 SID_ATTR_PARA_ORPHANS, SID_ATTR_PARA_ORPHANS,
80 0 );
81 aNewAttr.Put( rArgs );
83 // Die Werte sind erst einmal uebernommen worden, um den Dialog anzuzeigen.
84 // Muss natuerlich noch geaendert werden
85 // aNewAttr.Put( SvxParaDlgLimitsItem( 567 * 50, 5670) );
87 aNewAttr.Put( SvxHyphenZoneItem( false, SID_ATTR_PARA_HYPHENZONE ) );
88 aNewAttr.Put( SvxFmtBreakItem( SVX_BREAK_NONE, SID_ATTR_PARA_PAGEBREAK ) );
89 aNewAttr.Put( SvxFmtSplitItem( sal_True, SID_ATTR_PARA_SPLIT) );
90 aNewAttr.Put( SvxWidowsItem( 0, SID_ATTR_PARA_WIDOWS) );
91 aNewAttr.Put( SvxOrphansItem( 0, SID_ATTR_PARA_ORPHANS) );
93 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
94 OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
96 SfxAbstractTabDialog* pDlg = pFact->CreateScParagraphDlg( pViewData->GetDialogParent(), &aNewAttr, RID_SCDLG_PARAGRAPH);
97 OSL_ENSURE(pDlg, "Dialog create fail!");
98 sal_Bool bRet = ( pDlg->Execute() == RET_OK );
100 if ( bRet )
102 const SfxItemSet* pNewAttrs = pDlg->GetOutputItemSet();
103 if ( pNewAttrs )
104 rOutSet.Put( *pNewAttrs );
106 delete pDlg;
108 return bRet;
111 void ScDrawTextObjectBar::ExecutePasteContents( SfxRequest & /* rReq */ )
113 SdrView* pView = pViewData->GetScDrawView();
114 OutlinerView* pOutView = pView->GetTextEditOutlinerView();
115 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
116 SfxAbstractPasteDialog* pDlg = pFact->CreatePasteDialog( pViewData->GetDialogParent() );
118 pDlg->Insert( SOT_FORMAT_STRING, EMPTY_OUSTRING );
119 pDlg->Insert( SOT_FORMAT_RTF, EMPTY_OUSTRING );
121 TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) );
123 sal_uLong nFormat = pDlg->GetFormat( aDataHelper.GetTransferable() );
125 //! test if outliner view is still valid
127 if (nFormat > 0)
129 if (nFormat == SOT_FORMAT_STRING)
130 pOutView->Paste();
131 else
132 pOutView->PasteSpecial();
134 delete pDlg;
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */