fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / unoobj / editsrc.cxx
blob892708d78fb1db017d7d4857ff544c1a22fc1c43
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 <sal/config.h>
22 #include <utility>
24 #include "editsrc.hxx"
26 #include "scitems.hxx"
27 #include <editeng/eeitem.hxx>
28 #include <editeng/unofored.hxx>
29 #include <vcl/svapp.hxx>
30 #include <svx/svdpage.hxx>
31 #include <svx/svditer.hxx>
32 #include <svx/svdocapt.hxx>
33 #include <editeng/outlobj.hxx>
34 #include <editeng/editobj.hxx>
35 #include <editeng/outliner.hxx>
36 #include "textuno.hxx"
37 #include "editutil.hxx"
38 #include "docsh.hxx"
39 #include "docfunc.hxx"
40 #include "hints.hxx"
41 #include "patattr.hxx"
42 #include "drwlayer.hxx"
43 #include "userdat.hxx"
44 #include "postit.hxx"
45 #include "AccessibleText.hxx"
47 ScHeaderFooterEditSource::ScHeaderFooterEditSource(ScHeaderFooterTextData& rData) :
48 mrTextData(rData) {}
50 ScHeaderFooterEditSource::~ScHeaderFooterEditSource() {}
52 ScEditEngineDefaulter* ScHeaderFooterEditSource::GetEditEngine()
54 return mrTextData.GetEditEngine();
57 SvxEditSource* ScHeaderFooterEditSource::Clone() const
59 return new ScHeaderFooterEditSource(mrTextData);
62 SvxTextForwarder* ScHeaderFooterEditSource::GetTextForwarder()
64 return mrTextData.GetTextForwarder();
67 void ScHeaderFooterEditSource::UpdateData()
69 mrTextData.UpdateData();
72 ScCellEditSource::ScCellEditSource(ScDocShell* pDocSh, const ScAddress& rP) :
73 pCellTextData(new ScCellTextData(pDocSh, rP)) {}
75 ScCellEditSource::~ScCellEditSource()
77 delete pCellTextData;
80 SvxEditSource* ScCellEditSource::Clone() const
82 return new ScCellEditSource(pCellTextData->GetDocShell(), pCellTextData->GetCellPos());
85 SvxTextForwarder* ScCellEditSource::GetTextForwarder()
87 return pCellTextData->GetTextForwarder();
90 void ScCellEditSource::UpdateData()
92 pCellTextData->UpdateData();
95 void ScCellEditSource::SetDoUpdateData(bool bValue)
97 pCellTextData->SetDoUpdate(bValue);
100 bool ScCellEditSource::IsDirty() const
102 return pCellTextData->IsDirty();
105 ScEditEngineDefaulter* ScCellEditSource::GetEditEngine()
107 return pCellTextData->GetEditEngine();
110 ScAnnotationEditSource::ScAnnotationEditSource(ScDocShell* pDocSh, const ScAddress& rP) :
111 pDocShell( pDocSh ),
112 aCellPos( rP ),
113 pEditEngine( NULL ),
114 pForwarder( NULL ),
115 bDataValid( false )
117 if (pDocShell)
118 pDocShell->GetDocument().AddUnoObject(*this);
121 ScAnnotationEditSource::~ScAnnotationEditSource()
123 SolarMutexGuard aGuard; // needed for EditEngine dtor
125 if (pDocShell)
126 pDocShell->GetDocument().RemoveUnoObject(*this);
128 delete pForwarder;
129 delete pEditEngine;
132 SvxEditSource* ScAnnotationEditSource::Clone() const
134 return new ScAnnotationEditSource( pDocShell, aCellPos );
137 SdrObject* ScAnnotationEditSource::GetCaptionObj()
139 ScPostIt* pNote = pDocShell->GetDocument().GetNote(aCellPos);
140 return pNote ? pNote->GetOrCreateCaption( aCellPos ) : 0;
143 SvxTextForwarder* ScAnnotationEditSource::GetTextForwarder()
145 if (!pEditEngine)
147 // Notizen haben keine Felder
148 if ( pDocShell )
150 pEditEngine = new ScNoteEditEngine( pDocShell->GetDocument().GetNoteEngine() );
152 else
154 SfxItemPool* pEnginePool = EditEngine::CreatePool();
155 pEnginePool->FreezeIdRanges();
156 pEditEngine = new ScEditEngineDefaulter( pEnginePool, true );
158 pForwarder = new SvxEditEngineForwarder(*pEditEngine);
161 if (bDataValid)
162 return pForwarder;
164 if ( pDocShell )
165 if ( ScPostIt* pNote = pDocShell->GetDocument().GetNote(aCellPos) )
166 if ( const EditTextObject* pEditObj = pNote->GetEditTextObject() )
167 pEditEngine->SetText( *pEditObj ); // incl. Umbrueche
169 bDataValid = true;
170 return pForwarder;
173 void ScAnnotationEditSource::UpdateData()
175 if ( pDocShell && pEditEngine )
177 ScDocShellModificator aModificator( *pDocShell );
179 if( SdrObject* pObj = GetCaptionObj() )
181 EditTextObject* pEditObj = pEditEngine->CreateTextObject();
182 OutlinerParaObject* pOPO = new OutlinerParaObject( *pEditObj );
183 delete pEditObj;
184 pOPO->SetOutlinerMode( OUTLINERMODE_TEXTOBJECT );
185 pObj->NbcSetOutlinerParaObject( pOPO );
186 pObj->ActionChanged();
189 //! Undo !!!
191 aModificator.SetDocumentModified();
193 // bDataValid wird bei SetDocumentModified zurueckgesetzt
197 void ScAnnotationEditSource::Notify( SfxBroadcaster&, const SfxHint& rHint )
199 if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) )
201 //! Ref-Update
203 else if ( dynamic_cast<const SfxSimpleHint*>(&rHint) )
205 sal_uLong nId = static_cast<const SfxSimpleHint&>(rHint).GetId();
206 if ( nId == SFX_HINT_DYING )
208 pDocShell = NULL; // ungueltig geworden
210 DELETEZ( pForwarder );
211 DELETEZ( pEditEngine ); // EditEngine uses document's pool
213 else if ( nId == SFX_HINT_DATACHANGED )
214 bDataValid = false; // Text muss neu geholt werden
218 ScSimpleEditSource::ScSimpleEditSource( SvxTextForwarder* pForw ) :
219 pForwarder( pForw )
221 // The same forwarder (and EditEngine) is shared by all children of the same Text object.
222 // Text range and cursor keep a reference to their parent text, so the text object is
223 // always alive and the forwarder is valid as long as there are children.
226 ScSimpleEditSource::~ScSimpleEditSource()
230 SvxEditSource* ScSimpleEditSource::Clone() const
232 return new ScSimpleEditSource( pForwarder );
235 SvxTextForwarder* ScSimpleEditSource::GetTextForwarder()
237 return pForwarder;
240 void ScSimpleEditSource::UpdateData()
242 // nothing
245 ScAccessibilityEditSource::ScAccessibilityEditSource( ::std::unique_ptr < ScAccessibleTextData > && pAccessibleCellTextData )
246 : mpAccessibleTextData(std::move(pAccessibleCellTextData))
250 ScAccessibilityEditSource::~ScAccessibilityEditSource()
254 SvxEditSource* ScAccessibilityEditSource::Clone() const
256 return new ScAccessibilityEditSource(::std::unique_ptr < ScAccessibleTextData > (mpAccessibleTextData->Clone()));
259 SvxTextForwarder* ScAccessibilityEditSource::GetTextForwarder()
261 return mpAccessibleTextData->GetTextForwarder();
264 SvxViewForwarder* ScAccessibilityEditSource::GetViewForwarder()
266 return mpAccessibleTextData->GetViewForwarder();
269 SvxEditViewForwarder* ScAccessibilityEditSource::GetEditViewForwarder( bool bCreate )
271 return mpAccessibleTextData->GetEditViewForwarder(bCreate);
274 void ScAccessibilityEditSource::UpdateData()
276 mpAccessibleTextData->UpdateData();
279 SfxBroadcaster& ScAccessibilityEditSource::GetBroadcaster() const
281 return mpAccessibleTextData->GetBroadcaster();
284 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */