Branch data Line data Source code
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 <com/sun/star/accessibility/AccessibleEventId.hpp>
21 : : #include <com/sun/star/lang/Locale.hpp>
22 : : #include <com/sun/star/uno/Any.h>
23 : :
24 : : #include <comphelper/accessibletexthelper.hxx>
25 : : #include <comphelper/processfactory.hxx>
26 : : #include <comphelper/storagehelper.hxx>
27 : : #include <rtl/logfile.hxx>
28 : : #include <rtl/ustring.hxx>
29 : : #include <unotools/eventcfg.hxx>
30 : : #include <sfx2/event.hxx>
31 : : #include <sfx2/app.hxx>
32 : : #include <sfx2/dispatch.hxx>
33 : : #include <sfx2/docfile.hxx>
34 : : #include <sfx2/docfilt.hxx>
35 : : #include <sfx2/fcontnr.hxx>
36 : : #include <sfx2/msg.hxx>
37 : : #include <sfx2/objface.hxx>
38 : : #include <sfx2/printer.hxx>
39 : : #include <sfx2/request.hxx>
40 : : #include <sfx2/viewfrm.hxx>
41 : : #include <sot/clsids.hxx>
42 : : #include <sot/exchange.hxx>
43 : : #include <sot/formats.hxx>
44 : : #include <sot/storage.hxx>
45 : : #include <svl/eitem.hxx>
46 : : #include <svl/fstathelper.hxx>
47 : : #include <svl/intitem.hxx>
48 : : #include <svl/itempool.hxx>
49 : : #include <unotools/lingucfg.hxx>
50 : : #include <unotools/linguprops.hxx>
51 : : #include <unotools/pathoptions.hxx>
52 : : #include <svl/ptitem.hxx>
53 : : #include <svtools/sfxecode.hxx>
54 : : #include <svl/slstitm.hxx>
55 : : #include <svl/smplhint.hxx>
56 : : #include <svl/stritem.hxx>
57 : : #include <svtools/transfer.hxx>
58 : : #include <svl/undo.hxx>
59 : : #include <svl/urihelper.hxx>
60 : : #include <svl/whiter.hxx>
61 : : #include <editeng/editeng.hxx>
62 : : #include <editeng/editstat.hxx>
63 : : #include <editeng/eeitem.hxx>
64 : : #include <editeng/fhgtitem.hxx>
65 : : #include <editeng/fontitem.hxx>
66 : : #include <editeng/unolingu.hxx>
67 : : #include <ucbhelper/content.hxx>
68 : : #include <vcl/mapmod.hxx>
69 : : #include <tools/mapunit.hxx>
70 : : #include <vcl/msgbox.hxx>
71 : : #include <sfx2/sfx.hrc>
72 : : #include <document.hxx>
73 : : #include <action.hxx>
74 : : #include <config.hxx>
75 : : #include <dialog.hxx>
76 : : #include <format.hxx>
77 : : #include <smdll.hxx>
78 : : #include <starmath.hrc>
79 : : #include <symbol.hxx>
80 : : #include <toolbox.hxx>
81 : : #include <unomodel.hxx>
82 : : #include <utility.hxx>
83 : : #include <view.hxx>
84 : : #include "mathtype.hxx"
85 : : #include "ooxmlexport.hxx"
86 : : #include "ooxmlimport.hxx"
87 : : #include "rtfexport.hxx"
88 : : #include "mathmlimport.hxx"
89 : : #include "mathmlexport.hxx"
90 : : #include <sfx2/sfxsids.hrc>
91 : : #include <svx/svxids.hrc>
92 : : #include "cursor.hxx"
93 : : #include <tools/diagnose_ex.h>
94 : : #include "visitors.hxx"
95 : : #include "accessibility.hxx"
96 : :
97 : : using namespace ::com::sun::star;
98 : : using namespace ::com::sun::star::accessibility;
99 : : using namespace ::com::sun::star::lang;
100 : : using namespace ::com::sun::star::ucb;
101 : : using namespace ::com::sun::star::uno;
102 : :
103 : : #define SmDocShell
104 : : #include "smslots.hxx"
105 : :
106 : : ////////////////////////////////////////////////////////////
107 : :
108 : :
109 [ - + ][ + + ]: 19462 : TYPEINIT1( SmDocShell, SfxObjectShell );
110 : :
111 [ + + ][ + - ]: 1522 : SFX_IMPL_INTERFACE(SmDocShell, SfxObjectShell, SmResId(0))
[ + - ][ + - ]
112 : : {
113 [ + - ][ + - ]: 10 : SFX_POPUPMENU_REGISTRATION(SmResId(RID_VIEWMENU));
114 [ + - ][ + - ]: 10 : SFX_POPUPMENU_REGISTRATION(SmResId(RID_COMMANDMENU));
115 : 10 : }
116 : :
117 [ + + ][ + - ]: 13837 : SFX_IMPL_OBJECTFACTORY(SmDocShell, SvGlobalName(SO3_SM_CLASSID), SFXOBJECTSHELL_STD_NORMAL, "smath" )
[ + - ][ + - ]
[ + - ][ # # ]
118 : :
119 : 0 : void SmDocShell::SFX_NOTIFY(SfxBroadcaster&, const TypeId&,
120 : : const SfxHint& rHint, const TypeId&)
121 : : {
122 [ # # ]: 0 : switch (((SfxSimpleHint&)rHint).GetId())
123 : : {
124 : : case HINT_FORMATCHANGED:
125 : 0 : SetFormulaArranged(false);
126 : :
127 : 0 : nModifyCount++; //! see comment for SID_GAPHIC_SM in SmDocShell::GetState
128 : :
129 : 0 : Repaint();
130 : 0 : break;
131 : : }
132 : 0 : }
133 : :
134 : 0 : void SmDocShell::LoadSymbols()
135 : : {
136 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::LoadSymbols" );
137 : :
138 : 0 : SmModule *pp = SM_MOD();
139 : 0 : pp->GetSymbolManager().Load();
140 : 0 : }
141 : :
142 : :
143 : 0 : const String SmDocShell::GetComment() const
144 : : {
145 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::GetComment" );
146 : : uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
147 [ # # ][ # # ]: 0 : const_cast<SmDocShell*>(this)->GetModel(), uno::UNO_QUERY_THROW);
148 : : uno::Reference<document::XDocumentProperties> xDocProps(
149 [ # # ][ # # ]: 0 : xDPS->getDocumentProperties());
150 [ # # ][ # # ]: 0 : return xDocProps->getDescription();
[ # # ]
151 : : }
152 : :
153 : :
154 : 472 : void SmDocShell::SetText(const String& rBuffer)
155 : : {
156 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::SetText" );
157 : :
158 [ + + ]: 472 : if (rBuffer != aText)
159 : : {
160 : 438 : bool bIsEnabled = IsEnableSetModified();
161 [ + - ]: 438 : if( bIsEnabled )
162 : 438 : EnableSetModified( false );
163 : :
164 : 438 : aText = rBuffer;
165 : 438 : SetFormulaArranged( false );
166 : :
167 : 438 : Parse();
168 : :
169 : 438 : SmViewShell *pViewSh = SmGetActiveView();
170 [ + + ]: 438 : if( pViewSh )
171 : : {
172 : 12 : pViewSh->GetViewFrame()->GetBindings().Invalidate(SID_TEXT);
173 [ - + ]: 12 : if ( SFX_CREATE_MODE_EMBEDDED == GetCreateMode() )
174 : : {
175 : : // have SwOleClient::FormatChanged() to align the modified formula properly
176 : : // even if the vis area does not change (e.g. when formula text changes from
177 : : // "{a over b + c} over d" to "d over {a over b + c}"
178 [ # # ][ # # ]: 0 : SFX_APP()->NotifyEvent(SfxEventHint( SFX_EVENT_VISAREACHANGED, GlobalEventConfig::GetEventName(STR_EVENT_VISAREACHANGED), this));
[ # # ][ # # ]
179 : :
180 : 0 : Repaint();
181 : : }
182 : : else
183 : 12 : pViewSh->GetGraphicWindow().Invalidate();
184 : : }
185 : :
186 [ + - ]: 438 : if ( bIsEnabled )
187 : 438 : EnableSetModified( bIsEnabled );
188 : 438 : SetModified(true);
189 : :
190 : : // launch accessible event if necessary
191 [ + + ]: 438 : SmGraphicAccessible *pAcc = pViewSh ? pViewSh->GetGraphicWindow().GetAccessible_Impl() : 0;
192 [ - + ]: 438 : if (pAcc)
193 : : {
194 : 0 : Any aOldValue, aNewValue;
195 [ # # ][ # # ]: 0 : if ( comphelper::OCommonAccessibleText::implInitTextChangedEvent( aText, rBuffer, aOldValue, aNewValue ) )
[ # # ][ # # ]
196 : : {
197 : : pAcc->LaunchEvent( AccessibleEventId::TEXT_CHANGED,
198 [ # # ]: 0 : aOldValue, aNewValue );
199 : 0 : }
200 : : }
201 : :
202 [ + + ]: 438 : if ( GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
203 : 426 : OnDocumentPrinterChanged(0);
204 : : }
205 : 472 : }
206 : :
207 : 124 : void SmDocShell::SetFormat(SmFormat& rFormat)
208 : : {
209 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::SetFormat" );
210 : :
211 : 124 : aFormat = rFormat;
212 : 124 : SetFormulaArranged( false );
213 : 124 : SetModified( true );
214 : :
215 : 124 : nModifyCount++; //! see comment for SID_GAPHIC_SM in SmDocShell::GetState
216 : :
217 : : // don't use SmGetActiveView since the view shell might not be active (0 pointer)
218 : : // if for example the Basic Macro dialog currently has the focus. Thus:
219 : 124 : SfxViewFrame* pFrm = SfxViewFrame::GetFirst( this );
220 [ + + ]: 248 : while (pFrm)
221 : : {
222 : 124 : pFrm->GetBindings().Invalidate(SID_GAPHIC_SM);
223 : 124 : pFrm = SfxViewFrame::GetNext( *pFrm, this );
224 : : }
225 : 124 : }
226 : :
227 : 0 : String SmDocShell::GetAccessibleText()
228 : : {
229 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::GetAccessibleText" );
230 : :
231 [ # # ]: 0 : if (!IsFormulaArranged())
232 : 0 : ArrangeFormula();
233 [ # # ]: 0 : if (0 == aAccText.Len())
234 : : {
235 : : OSL_ENSURE( pTree, "Tree missing" );
236 [ # # ]: 0 : if (pTree)
237 : 0 : pTree->GetAccessibleText( aAccText );
238 : : }
239 : 0 : return aAccText;
240 : : }
241 : :
242 : 472 : void SmDocShell::Parse()
243 : : {
244 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::Parse" );
245 : :
246 [ + + ]: 472 : if (pTree)
247 [ + - ]: 12 : delete pTree;
248 : 472 : ReplaceBadChars();
249 : 472 : pTree = aInterpreter.Parse(aText);
250 : 472 : nModifyCount++; //! see comment for SID_GAPHIC_SM in SmDocShell::GetState
251 : 472 : SetFormulaArranged( false );
252 : 472 : InvalidateCursor();
253 [ + - ]: 472 : aUsedSymbols = aInterpreter.GetUsedSymbols();
254 : 472 : }
255 : :
256 : :
257 : 1436 : void SmDocShell::ArrangeFormula()
258 : : {
259 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::ArrangeFormula" );
260 : :
261 [ + - ]: 1436 : if (IsFormulaArranged())
262 : 1436 : return;
263 : :
264 : : // Only for the duration of the existence of this object the correct settings
265 : : // at the printer are guaranteed!
266 [ + - ]: 1436 : SmPrinterAccess aPrtAcc(*this);
267 : 1436 : OutputDevice* pOutDev = aPrtAcc.GetRefDev();
268 : :
269 : : if (!pOutDev)
270 : : {
271 : : #if OSL_DEBUG_LEVEL > 1
272 : : OSL_FAIL("!! SmDocShell::ArrangeFormula: reference device missing !!");
273 : : #endif
274 : : }
275 : :
276 : : // if neccessary get another OutputDevice for which we format
277 [ + + ]: 1436 : if (!pOutDev)
278 : : {
279 [ + - ]: 426 : SmViewShell *pView = SmGetActiveView();
280 [ - + ]: 426 : if (pView)
281 : 0 : pOutDev = &pView->GetGraphicWindow();
282 : : else
283 : : {
284 [ + - ][ + - ]: 426 : pOutDev = &SM_MOD()->GetDefaultVirtualDev();
285 [ + - ][ + - ]: 426 : pOutDev->SetMapMode( MapMode(MAP_100TH_MM) );
[ + - ]
286 : : }
287 : : }
288 : : OSL_ENSURE(pOutDev->GetMapMode().GetMapUnit() == MAP_100TH_MM,
289 : : "Sm : falscher MapMode");
290 : :
291 : 1436 : const SmFormat &rFormat = GetFormat();
292 [ + - ]: 1436 : pTree->Prepare(rFormat, *this);
293 : :
294 : : // format/draw formulas always from left to right,
295 : : // and numbers should not be converted
296 : 1436 : sal_uLong nLayoutMode = pOutDev->GetLayoutMode();
297 [ + - ]: 1436 : pOutDev->SetLayoutMode( TEXT_LAYOUT_BIDI_LTR );
298 : 1436 : sal_Int16 nDigitLang = pOutDev->GetDigitLanguage();
299 [ + - ]: 1436 : pOutDev->SetDigitLanguage( LANGUAGE_ENGLISH );
300 : : //
301 [ + - ]: 1436 : pTree->Arrange(*pOutDev, rFormat);
302 : : //
303 [ + - ]: 1436 : pOutDev->SetLayoutMode( nLayoutMode );
304 [ + - ]: 1436 : pOutDev->SetDigitLanguage( nDigitLang );
305 : :
306 : 1436 : SetFormulaArranged(true);
307 : :
308 : : // invalidate accessible text
309 [ + - ][ + - ]: 1436 : aAccText = String();
[ + - ][ + - ]
310 : : }
311 : :
312 : :
313 : 34 : void SetEditEngineDefaultFonts(SfxItemPool &rEditEngineItemPool)
314 : : {
315 : : //
316 : : // set fonts to be used
317 : : //
318 [ + - ]: 34 : SvtLinguOptions aOpt;
319 [ + - ][ + - ]: 34 : SvtLinguConfig().GetOptions( aOpt );
[ + - ]
320 : : //
321 : : struct FontDta {
322 : : sal_Int16 nFallbackLang;
323 : : sal_Int16 nLang;
324 : : sal_uInt16 nFontType;
325 : : sal_uInt16 nFontInfoId;
326 : : } aTable[3] =
327 : : {
328 : : // info to get western font to be used
329 : : { LANGUAGE_ENGLISH_US, LANGUAGE_NONE,
330 : : DEFAULTFONT_FIXED, EE_CHAR_FONTINFO },
331 : : // info to get CJK font to be used
332 : : { LANGUAGE_JAPANESE, LANGUAGE_NONE,
333 : : DEFAULTFONT_CJK_TEXT, EE_CHAR_FONTINFO_CJK },
334 : : // info to get CTL font to be used
335 : : { LANGUAGE_ARABIC_SAUDI_ARABIA, LANGUAGE_NONE,
336 : : DEFAULTFONT_CTL_TEXT, EE_CHAR_FONTINFO_CTL }
337 : 34 : };
338 : 34 : aTable[0].nLang = aOpt.nDefaultLanguage;
339 : 34 : aTable[1].nLang = aOpt.nDefaultLanguage_CJK;
340 : 34 : aTable[2].nLang = aOpt.nDefaultLanguage_CTL;
341 : : //
342 [ + + ]: 136 : for (int i = 0; i < 3; ++i)
343 : : {
344 : 102 : const FontDta &rFntDta = aTable[i];
345 : : LanguageType nLang = (LANGUAGE_NONE == rFntDta.nLang) ?
346 [ - + ]: 102 : rFntDta.nFallbackLang : rFntDta.nLang;
347 [ + - ]: 102 : Font aFont = Application::GetDefaultDevice()->GetDefaultFont(
348 [ + - ][ + - ]: 102 : rFntDta.nFontType, nLang, DEFAULTFONT_FLAGS_ONLYONE );
[ + - ]
349 : : rEditEngineItemPool.SetPoolDefaultItem(
350 [ + - ]: 102 : SvxFontItem( aFont.GetFamily(), aFont.GetName(),
351 [ + - ][ + - ]: 204 : aFont.GetStyleName(), aFont.GetPitch(), aFont.GetCharSet(),
352 [ + - ][ + - ]: 204 : rFntDta.nFontInfoId ) );
[ + - ][ + - ]
[ + - ]
353 [ + - ]: 102 : }
354 : :
355 : : // set font heights
356 : : SvxFontHeightItem aFontHeigt(
357 : : Application::GetDefaultDevice()->LogicToPixel(
358 [ + - ][ + - ]: 68 : Size( 0, 11 ), MapMode( MAP_POINT ) ).Height(), 100,
[ + - ][ + - ]
359 [ + - ]: 34 : EE_CHAR_FONTHEIGHT );
360 [ + - ]: 34 : rEditEngineItemPool.SetPoolDefaultItem( aFontHeigt );
361 : 34 : aFontHeigt.SetWhich( EE_CHAR_FONTHEIGHT_CJK );
362 [ + - ]: 34 : rEditEngineItemPool.SetPoolDefaultItem( aFontHeigt );
363 : 34 : aFontHeigt.SetWhich( EE_CHAR_FONTHEIGHT_CTL );
364 [ + - ][ + - ]: 34 : rEditEngineItemPool.SetPoolDefaultItem( aFontHeigt );
[ + - ]
365 : 34 : }
366 : :
367 : :
368 : 102 : EditEngine& SmDocShell::GetEditEngine()
369 : : {
370 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::GetEditEngine" );
371 : :
372 [ + + ]: 102 : if (!pEditEngine)
373 : : {
374 : : //!
375 : : //! see also SmEditWindow::DataChanged !
376 : : //!
377 : :
378 [ + - ]: 34 : pEditEngineItemPool = EditEngine::CreatePool();
379 : :
380 [ + - ]: 34 : SetEditEngineDefaultFonts(*pEditEngineItemPool);
381 : :
382 [ + - ][ + - ]: 34 : pEditEngine = new EditEngine( pEditEngineItemPool );
383 : :
384 [ + - ]: 34 : pEditEngine->EnableUndo( true );
385 : : pEditEngine->SetDefTab( sal_uInt16(
386 [ + - ][ + - ]: 34 : Application::GetDefaultDevice()->GetTextWidth(rtl::OUString("XXXX"))) );
[ + - ][ + - ]
[ + - ]
387 : :
388 : : pEditEngine->SetControlWord(
389 [ + - ]: 34 : (pEditEngine->GetControlWord() | EE_CNTRL_AUTOINDENTING) &
390 : : (~EE_CNTRL_UNDOATTRIBS) &
391 [ + - ]: 34 : (~EE_CNTRL_PASTESPECIAL) );
392 : :
393 [ + - ][ + - ]: 34 : pEditEngine->SetWordDelimiters( rtl::OUString(" .=+-*/(){}[];\"" ) );
[ + - ]
394 [ + - ][ + - ]: 34 : pEditEngine->SetRefMapMode( MAP_PIXEL );
[ + - ]
395 : :
396 [ + - ]: 34 : pEditEngine->SetPaperSize( Size( 800, 0 ) );
397 : :
398 [ + - ]: 34 : pEditEngine->EraseVirtualDevice();
399 : :
400 : : // set initial text if the document already has some...
401 : : // (may be the case when reloading a doc)
402 [ + - ]: 34 : String aTxt( GetText() );
403 [ - + ]: 34 : if (aTxt.Len())
404 [ # # ]: 0 : pEditEngine->SetText( aTxt );
405 : :
406 [ + - ][ + - ]: 34 : pEditEngine->ClearModifyFlag();
407 : :
408 : : }
409 : 102 : return *pEditEngine;
410 : : }
411 : :
412 : :
413 : 0 : SfxItemPool& SmDocShell::GetEditEngineItemPool()
414 : : {
415 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::GetEditEngineItemPool" );
416 : :
417 [ # # ]: 0 : if (!pEditEngineItemPool)
418 : 0 : GetEditEngine();
419 : : OSL_ENSURE( pEditEngineItemPool, "EditEngineItemPool missing" );
420 : 0 : return *pEditEngineItemPool;
421 : : }
422 : :
423 : 6855 : void SmDocShell::DrawFormula(OutputDevice &rDev, Point &rPosition, bool bDrawSelection)
424 : : {
425 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::Draw" );
426 : :
427 [ - + ]: 6855 : if (!pTree)
428 : 0 : Parse();
429 : : OSL_ENSURE(pTree, "Sm : NULL pointer");
430 : :
431 [ - + ]: 6855 : if (!IsFormulaArranged())
432 : 0 : ArrangeFormula();
433 : :
434 : : // Problem: What happens to WYSIWYG? While we're active inplace, we don't have a reference
435 : : // device and aren't aligned to that either. So now there can be a difference between the
436 : : // VisArea (i.e. the size within the client) and the current size.
437 : : // Idea: The difference could be adapted with SmNod::SetSize (no long-term solution)
438 : :
439 : 6855 : rPosition.X() += aFormat.GetDistance( DIS_LEFTSPACE );
440 : 6855 : rPosition.Y() += aFormat.GetDistance( DIS_TOPSPACE );
441 : :
442 : : //! in case of high contrast-mode (accessibility option!)
443 : : //! the draw mode needs to be set to default, because when imbedding
444 : : //! Math for example in Calc in "a over b" the fraction bar may not
445 : : //! be visible else. More generally: the FillColor may have been changed.
446 : 6855 : sal_uLong nOldDrawMode = DRAWMODE_DEFAULT;
447 : 6855 : bool bRestoreDrawMode = false;
448 [ - + ]: 6894 : if (OUTDEV_WINDOW == rDev.GetOutDevType() &&
[ + + - + ]
449 : 39 : ((Window &) rDev).GetSettings().GetStyleSettings().GetHighContrastMode())
450 : : {
451 : 0 : nOldDrawMode = rDev.GetDrawMode();
452 : 0 : rDev.SetDrawMode( DRAWMODE_DEFAULT );
453 : 0 : bRestoreDrawMode = true;
454 : : }
455 : :
456 : : // format/draw formulas always from left to right
457 : : // and numbers should not be converted
458 : 6855 : sal_uLong nLayoutMode = rDev.GetLayoutMode();
459 : 6855 : rDev.SetLayoutMode( TEXT_LAYOUT_BIDI_LTR );
460 : 6855 : sal_Int16 nDigitLang = rDev.GetDigitLanguage();
461 : 6855 : rDev.SetDigitLanguage( LANGUAGE_ENGLISH );
462 : :
463 : : //Set selection if any
464 [ # # ][ - + ]: 6855 : if(pCursor && bDrawSelection){
465 : 0 : pCursor->AnnotateSelection();
466 : 0 : SmSelectionDrawingVisitor(rDev, pTree, rPosition);
467 : : }
468 : :
469 : : //Drawing using visitor
470 : 6855 : SmDrawingVisitor(rDev, rPosition, pTree);
471 : :
472 : : //
473 : 6855 : rDev.SetLayoutMode( nLayoutMode );
474 : 6855 : rDev.SetDigitLanguage( nDigitLang );
475 : :
476 [ - + ]: 6855 : if (bRestoreDrawMode)
477 : 0 : rDev.SetDrawMode( nOldDrawMode );
478 : 6855 : }
479 : :
480 : :
481 : :
482 : 1869 : Size SmDocShell::GetSize()
483 : : {
484 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::GetSize" );
485 : :
486 : 1869 : Size aRet;
487 : :
488 [ + + ]: 1869 : if (!pTree)
489 : 34 : Parse();
490 : :
491 [ + - ]: 1869 : if (pTree)
492 : : {
493 [ + + ]: 1869 : if (!IsFormulaArranged())
494 : 1436 : ArrangeFormula();
495 : 1869 : aRet = pTree->GetSize();
496 : :
497 [ - + ]: 1869 : if ( !aRet.Width() )
498 : 0 : aRet.Width() = 2000;
499 : : else
500 : 3738 : aRet.Width() += aFormat.GetDistance( DIS_LEFTSPACE ) +
501 : 3738 : aFormat.GetDistance( DIS_RIGHTSPACE );
502 [ - + ]: 1869 : if ( !aRet.Height() )
503 : 0 : aRet.Height() = 1000;
504 : : else
505 : 3738 : aRet.Height() += aFormat.GetDistance( DIS_TOPSPACE ) +
506 : 3738 : aFormat.GetDistance( DIS_BOTTOMSPACE );
507 : : }
508 : :
509 : 1869 : return aRet;
510 : : }
511 : :
512 : 472 : void SmDocShell::InvalidateCursor(){
513 [ - + ]: 472 : delete pCursor;
514 : 472 : pCursor = NULL;
515 : 472 : }
516 : :
517 : 0 : SmCursor& SmDocShell::GetCursor(){
518 [ # # ]: 0 : if(!pCursor)
519 [ # # ]: 0 : pCursor = new SmCursor(pTree, this);
520 : 0 : return *pCursor;
521 : : }
522 : :
523 : : ////////////////////////////////////////
524 : :
525 : 1436 : SmPrinterAccess::SmPrinterAccess( SmDocShell &rDocShell )
526 : : {
527 [ + + ]: 1436 : if ( 0 != (pPrinter = rDocShell.GetPrt()) )
528 : : {
529 : 158 : pPrinter->Push( PUSH_MAPMODE );
530 [ - + ]: 158 : if ( SFX_CREATE_MODE_EMBEDDED == rDocShell.GetCreateMode() )
531 : : {
532 : : // if it is an embedded object (without it's own printer)
533 : : // we change the MapMode temporarily.
534 : : //!If it is a document with it's own printer the MapMode should
535 : : //!be set correct (once) elsewhere(!), in order to avoid numerous
536 : : //!superfluous pushing and poping of the MapMode when using
537 : : //!this class.
538 : :
539 : 0 : const MapUnit eOld = pPrinter->GetMapMode().GetMapUnit();
540 [ # # ]: 0 : if ( MAP_100TH_MM != eOld )
541 : : {
542 [ # # ]: 0 : MapMode aMap( pPrinter->GetMapMode() );
543 [ # # ]: 0 : aMap.SetMapUnit( MAP_100TH_MM );
544 : 0 : Point aTmp( aMap.GetOrigin() );
545 [ # # ]: 0 : aTmp.X() = OutputDevice::LogicToLogic( aTmp.X(), eOld, MAP_100TH_MM );
546 [ # # ]: 0 : aTmp.Y() = OutputDevice::LogicToLogic( aTmp.Y(), eOld, MAP_100TH_MM );
547 [ # # ]: 0 : aMap.SetOrigin( aTmp );
548 [ # # ][ # # ]: 0 : pPrinter->SetMapMode( aMap );
549 : : }
550 : : }
551 : : }
552 [ + + ][ + + ]: 1436 : if ( 0 != (pRefDev = rDocShell.GetRefDev()) && pPrinter != pRefDev )
[ + + ]
553 : : {
554 : 852 : pRefDev->Push( PUSH_MAPMODE );
555 [ + - ]: 852 : if ( SFX_CREATE_MODE_EMBEDDED == rDocShell.GetCreateMode() )
556 : : {
557 : : // if it is an embedded object (without it's own printer)
558 : : // we change the MapMode temporarily.
559 : : //!If it is a document with it's own printer the MapMode should
560 : : //!be set correct (once) elsewhere(!), in order to avoid numerous
561 : : //!superfluous pushing and poping of the MapMode when using
562 : : //!this class.
563 : :
564 : 852 : const MapUnit eOld = pRefDev->GetMapMode().GetMapUnit();
565 [ + - ]: 852 : if ( MAP_100TH_MM != eOld )
566 : : {
567 [ + - ]: 852 : MapMode aMap( pRefDev->GetMapMode() );
568 [ + - ]: 852 : aMap.SetMapUnit( MAP_100TH_MM );
569 : 852 : Point aTmp( aMap.GetOrigin() );
570 [ + - ]: 852 : aTmp.X() = OutputDevice::LogicToLogic( aTmp.X(), eOld, MAP_100TH_MM );
571 [ + - ]: 852 : aTmp.Y() = OutputDevice::LogicToLogic( aTmp.Y(), eOld, MAP_100TH_MM );
572 [ + - ]: 852 : aMap.SetOrigin( aTmp );
573 [ + - ][ + - ]: 852 : pRefDev->SetMapMode( aMap );
574 : : }
575 : : }
576 : : }
577 : 1436 : }
578 : :
579 : 1436 : SmPrinterAccess::~SmPrinterAccess()
580 : : {
581 [ + + ]: 1436 : if ( pPrinter )
582 : 158 : pPrinter->Pop();
583 [ + + ][ + + ]: 1436 : if ( pRefDev && pRefDev != pPrinter )
584 : 852 : pRefDev->Pop();
585 : 1436 : }
586 : :
587 : : ////////////////////////////////////////
588 : :
589 : 3818 : Printer* SmDocShell::GetPrt()
590 : : {
591 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::GetPrt" );
592 : :
593 [ + + ]: 3818 : if ( SFX_CREATE_MODE_EMBEDDED == GetCreateMode() )
594 : : {
595 : : // Normally the server provides the printer. But if it doesn't provide one (e.g. because
596 : : // there is no connection) it still can be the case that we know the printer because it
597 : : // has been passed on by the server in OnDocumentPrinterChanged and being kept temporarily.
598 : 3408 : Printer *pPrt = GetDocumentPrinter();
599 [ - + ][ + - ]: 3408 : if ( !pPrt && pTmpPrinter )
600 : 0 : pPrt = pTmpPrinter;
601 : 3408 : return pPrt;
602 : : }
603 [ + + ]: 410 : else if ( !pPrinter )
604 : : {
605 : : SfxItemSet *pOptions =
606 : 34 : new SfxItemSet(GetPool(),
607 : : SID_PRINTSIZE, SID_PRINTSIZE,
608 : : SID_PRINTZOOM, SID_PRINTZOOM,
609 : : SID_PRINTTITLE, SID_PRINTTITLE,
610 : : SID_PRINTTEXT, SID_PRINTTEXT,
611 : : SID_PRINTFRAME, SID_PRINTFRAME,
612 : : SID_NO_RIGHT_SPACES, SID_NO_RIGHT_SPACES,
613 [ + - ]: 34 : 0);
614 : :
615 : 34 : SmModule *pp = SM_MOD();
616 : 34 : pp->GetConfig()->ConfigToItemSet(*pOptions);
617 [ + - ]: 34 : pPrinter = new SfxPrinter(pOptions);
618 [ + - ]: 34 : pPrinter->SetMapMode( MapMode(MAP_100TH_MM) );
619 : : }
620 : 3818 : return pPrinter;
621 : : }
622 : :
623 : 1436 : OutputDevice* SmDocShell::GetRefDev()
624 : : {
625 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::GetRefDev" );
626 : :
627 [ + + ]: 1436 : if ( SFX_CREATE_MODE_EMBEDDED == GetCreateMode() )
628 : : {
629 : 1278 : OutputDevice* pOutDev = GetDocumentRefDev();
630 [ + + ]: 1278 : if ( pOutDev )
631 : 852 : return pOutDev;
632 : : }
633 : :
634 : 1436 : return GetPrt();
635 : : }
636 : :
637 : :
638 : 0 : void SmDocShell::SetPrinter( SfxPrinter *pNew )
639 : : {
640 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::SetPrinter" );
641 : :
642 [ # # ]: 0 : delete pPrinter;
643 : 0 : pPrinter = pNew; //Eigentumsuebergang!
644 [ # # ]: 0 : pPrinter->SetMapMode( MapMode(MAP_100TH_MM) );
645 : 0 : SetFormulaArranged(false);
646 : 0 : Repaint();
647 : 0 : }
648 : :
649 : 1278 : void SmDocShell::OnDocumentPrinterChanged( Printer *pPrt )
650 : : {
651 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::OnDocumentPrinterChanged" );
652 : :
653 : 1278 : pTmpPrinter = pPrt;
654 : 1278 : SetFormulaArranged(false);
655 [ + - ][ + - ]: 1278 : Size aOldSize = GetVisArea().GetSize();
656 [ + - ]: 1278 : Repaint();
657 [ + - ][ + - ]: 1278 : if( aOldSize != GetVisArea().GetSize() && aText.Len() )
[ + + ][ + - ]
[ + - ]
[ + + # # ]
658 [ + - ]: 426 : SetModified( true );
659 : 1278 : pTmpPrinter = 0;
660 : 1278 : }
661 : :
662 : 1278 : void SmDocShell::Repaint()
663 : : {
664 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::Repaint" );
665 : :
666 [ + - ]: 1278 : bool bIsEnabled = IsEnableSetModified();
667 [ + - ]: 1278 : if ( bIsEnabled )
668 [ + - ]: 1278 : EnableSetModified( false );
669 : :
670 : 1278 : SetFormulaArranged( false );
671 : :
672 [ + - ]: 1278 : Size aVisSize = GetSize();
673 [ + - ]: 1278 : SetVisAreaSize( aVisSize );
674 [ + - ]: 1278 : SmViewShell *pViewSh = SmGetActiveView();
675 [ - + ]: 1278 : if (pViewSh)
676 [ # # ]: 0 : pViewSh->GetGraphicWindow().Invalidate();
677 : :
678 [ + - ]: 1278 : if ( bIsEnabled )
679 [ + - ]: 1278 : EnableSetModified( bIsEnabled );
680 : 1278 : }
681 : :
682 : :
683 : 460 : SmDocShell::SmDocShell( const sal_uInt64 i_nSfxCreationFlags ) :
684 : : SfxObjectShell( i_nSfxCreationFlags ),
685 : : pTree ( 0 ),
686 : : pEditEngineItemPool ( 0 ),
687 : : pEditEngine ( 0 ),
688 : : pPrinter ( 0 ),
689 : : pTmpPrinter ( 0 ),
690 : : nModifyCount ( 0 ),
691 [ + - ][ + - ]: 460 : bIsFormulaArranged ( false )
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
692 : : {
693 : 460 : pCursor = NULL;
694 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::SmDocShell" );
695 : :
696 [ + - ][ # # ]: 460 : SetPool(&SFX_APP()->GetPool());
697 : :
698 [ + - # # ]: 460 : SmModule *pp = SM_MOD();
699 [ + - ][ + - ]: 460 : aFormat = pp->GetConfig()->GetStandardFormat();
[ + - ][ # # ]
[ # # ][ # # ]
700 : :
701 [ + - ][ # # ]: 460 : StartListening(aFormat);
702 [ + - ][ + - ]: 460 : StartListening(*pp->GetConfig());
[ # # ][ # # ]
703 : :
704 [ + - ][ + - ]: 460 : SetBaseModel( new SmModel(this) );
[ # # ][ # # ]
705 : 460 : }
706 : :
707 : :
708 : :
709 [ + - ][ + - ]: 1227 : SmDocShell::~SmDocShell()
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
710 : : {
711 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::~SmDocShell" );
712 : :
713 [ + - ][ # # ]: 409 : SmModule *pp = SM_MOD();
714 : :
715 [ + - ][ # # ]: 409 : EndListening(aFormat);
716 [ + - ][ + - ]: 409 : EndListening(*pp->GetConfig());
[ # # ][ # # ]
717 : :
718 : :
719 [ - + ][ # # ]: 409 : if(pCursor)
720 [ # # ][ # # ]: 0 : delete pCursor;
[ # # ][ # # ]
721 : 409 : pCursor = NULL;
722 : :
723 [ + + ][ + - ]: 409 : delete pEditEngine;
[ # # ][ # # ]
724 [ + - ][ # # ]: 409 : SfxItemPool::Free(pEditEngineItemPool);
725 [ + - ][ + - ]: 409 : delete pTree;
[ # # ][ # # ]
726 [ + + ][ + - ]: 409 : delete pPrinter;
[ # # ][ # # ]
727 [ + - ][ + - ]: 1636 : }
[ - + ]
[ # # # # ]
[ # # ][ # # ]
[ # # ]
[ # # # # ]
728 : :
729 : :
730 : 0 : sal_Bool SmDocShell::SetData( const String& rData )
731 : : {
732 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::SetData" );
733 : :
734 : 0 : SetText( rData );
735 : 0 : return true;
736 : : }
737 : :
738 : :
739 : 0 : sal_Bool SmDocShell::ConvertFrom(SfxMedium &rMedium)
740 : : {
741 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::ConvertFrom" );
742 : :
743 : 0 : bool bSuccess = false;
744 : 0 : const String& rFltName = rMedium.GetFilter()->GetFilterName();
745 : :
746 : : OSL_ENSURE( !rFltName.EqualsAscii( STAROFFICE_XML ), "Wrong filter!");
747 : :
748 [ # # ]: 0 : if ( rFltName.EqualsAscii( MATHML_XML ) )
749 : : {
750 [ # # ]: 0 : if (pTree)
751 : : {
752 [ # # ][ # # ]: 0 : delete pTree;
753 : 0 : pTree = 0;
754 [ # # ]: 0 : InvalidateCursor();
755 : : }
756 [ # # ]: 0 : Reference<com::sun::star::frame::XModel> xModel(GetModel());
757 [ # # ]: 0 : SmXMLImportWrapper aEquation(xModel);
758 [ # # ][ # # ]: 0 : bSuccess = 0 == aEquation.Import(rMedium);
759 : : }
760 : : else
761 : : {
762 : 0 : SvStream *pStream = rMedium.GetInStream();
763 [ # # ]: 0 : if ( pStream )
764 : : {
765 [ # # ]: 0 : if ( SotStorage::IsStorageFile( pStream ) )
766 : : {
767 [ # # ][ # # ]: 0 : SvStorageRef aStorage = new SotStorage( pStream, false );
768 [ # # ][ # # ]: 0 : if ( aStorage->IsStream(rtl::OUString("Equation Native")) )
[ # # ][ # # ]
769 : : {
770 : : // is this a MathType Storage?
771 [ # # ]: 0 : MathType aEquation( aText );
772 [ # # ][ # # ]: 0 : if ( true == (bSuccess = (1 == aEquation.Parse( aStorage )) ))
773 [ # # ][ # # ]: 0 : Parse();
774 [ # # ]: 0 : }
775 : : }
776 : : }
777 : : }
778 : :
779 [ # # ]: 0 : if ( GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
780 : : {
781 : 0 : SetFormulaArranged( false );
782 : 0 : Repaint();
783 : : }
784 : :
785 : 0 : FinishedLoading( SFX_LOADED_ALL );
786 : 0 : return bSuccess;
787 : : }
788 : :
789 : :
790 : 460 : sal_Bool SmDocShell::InitNew( const uno::Reference < embed::XStorage >& xStorage )
791 : : {
792 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::InitNew" );
793 : :
794 : 460 : bool bRet = false;
795 [ + - ]: 460 : if ( SfxObjectShell::InitNew( xStorage ) )
796 : : {
797 : 460 : bRet = true;
798 [ + - ][ + - ]: 460 : SetVisArea(Rectangle(Point(0, 0), Size(2000, 1000)));
799 : : }
800 : 460 : return bRet;
801 : : }
802 : :
803 : :
804 : 0 : sal_Bool SmDocShell::Load( SfxMedium& rMedium )
805 : : {
806 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::Load" );
807 : :
808 : 0 : bool bRet = false;
809 [ # # ]: 0 : if( SfxObjectShell::Load( rMedium ))
810 : : {
811 [ # # ]: 0 : uno::Reference < embed::XStorage > xStorage = GetMedium()->GetStorage();
812 [ # # ]: 0 : uno::Reference < container::XNameAccess > xAccess (xStorage, uno::UNO_QUERY);
813 [ # # ][ # # ]: 0 : if (
[ # # ][ # # ]
[ # # ]
814 : : (
815 [ # # ][ # # ]: 0 : xAccess->hasByName( rtl::OUString("content.xml") ) &&
[ # # ][ # # ]
[ # # # # ]
816 [ # # ][ # # ]: 0 : xStorage->isStreamElement( rtl::OUString("content.xml") )
[ # # ][ # # ]
[ # # # # ]
817 : : ) ||
818 : : (
819 [ # # ][ # # ]: 0 : xAccess->hasByName( rtl::OUString("Content.xml") ) &&
[ # # ][ # # ]
[ # # # # ]
820 [ # # ][ # # ]: 0 : xStorage->isStreamElement( rtl::OUString("Content.xml") )
[ # # ][ # # ]
[ # # # # ]
821 : : )
822 : : )
823 : : {
824 : : // is this a fabulous math package ?
825 [ # # ]: 0 : Reference<com::sun::star::frame::XModel> xModel(GetModel());
826 [ # # ]: 0 : SmXMLImportWrapper aEquation(xModel);
827 [ # # ]: 0 : sal_uLong nError = aEquation.Import(rMedium);
828 : 0 : bRet = 0 == nError;
829 [ # # ][ # # ]: 0 : SetError( nError, OSL_LOG_PREFIX );
830 : 0 : }
831 : : }
832 : :
833 [ # # ]: 0 : if ( GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
834 : : {
835 : 0 : SetFormulaArranged( false );
836 : 0 : Repaint();
837 : : }
838 : :
839 : 0 : FinishedLoading( SFX_LOADED_ALL );
840 : 0 : return bRet;
841 : : }
842 : :
843 : : //------------------------------------------------------------------
844 : :
845 : 0 : sal_Bool SmDocShell::Save()
846 : : {
847 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::Save" );
848 : :
849 : : //! apply latest changes if necessary
850 : 0 : UpdateText();
851 : :
852 [ # # ]: 0 : if ( SfxObjectShell::Save() )
853 : : {
854 [ # # ]: 0 : if (!pTree)
855 [ # # ]: 0 : Parse();
856 [ # # ][ # # ]: 0 : if( pTree && !IsFormulaArranged() )
[ # # ]
857 [ # # ]: 0 : ArrangeFormula();
858 : :
859 [ # # ]: 0 : Reference<com::sun::star::frame::XModel> xModel(GetModel());
860 [ # # ]: 0 : SmXMLExportWrapper aEquation(xModel);
861 : 0 : aEquation.SetFlat(sal_False);
862 [ # # ][ # # ]: 0 : return aEquation.Export(*GetMedium());
863 : : }
864 : :
865 : 0 : return false;
866 : : }
867 : :
868 : : /*
869 : : * replace bad characters that can not be saved. (#i74144)
870 : : * */
871 : 472 : sal_Bool SmDocShell::ReplaceBadChars()
872 : : {
873 : 472 : sal_Bool bReplace = sal_False;
874 [ + + ]: 472 : if (pEditEngine)
875 : : {
876 [ + - ]: 12 : String aEngTxt( pEditEngine->GetText( LINEEND_LF ) );
877 : 12 : const sal_Unicode *pEngTxt = aEngTxt.GetBuffer();
878 : 12 : xub_StrLen nLen = aEngTxt.Len();
879 [ - + ][ # # ]: 12 : for (xub_StrLen i = 0; i < nLen && !bReplace; ++i)
[ - + ]
880 : : {
881 : 0 : const sal_Unicode c = *pEngTxt++;
882 [ # # ][ # # ]: 0 : if (c < ' ' && c != '\r' && c != '\n' && c != '\t')
[ # # ][ # # ]
883 : 0 : bReplace = sal_True;
884 : : }
885 [ - + ]: 12 : if (bReplace)
886 : : {
887 [ # # ]: 0 : sal_Unicode *pChgTxt = aEngTxt.GetBufferAccess();
888 [ # # ]: 0 : for (xub_StrLen i = 0; i < nLen; ++i)
889 : : {
890 : 0 : sal_Unicode &rc = *pChgTxt++;
891 [ # # ][ # # ]: 0 : if (rc < ' ' && rc != '\r' && rc != '\n' && rc != '\t')
[ # # ][ # # ]
892 : 0 : rc = ' ';
893 : : }
894 [ # # ]: 0 : aEngTxt.ReleaseBufferAccess( nLen );
895 : :
896 [ # # ]: 0 : aText = aEngTxt;
897 [ + - ]: 12 : }
898 : : }
899 : 472 : return bReplace;
900 : : }
901 : :
902 : :
903 : 852 : void SmDocShell::UpdateText()
904 : : {
905 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::UpdateText" );
906 : :
907 [ - + ][ # # ]: 852 : if (pEditEngine && pEditEngine->IsModified())
[ - + ]
908 : : {
909 [ # # ]: 0 : String aEngTxt( pEditEngine->GetText( LINEEND_LF ) );
910 [ # # ][ # # ]: 0 : if (GetText() != aEngTxt)
911 [ # # ][ # # ]: 0 : SetText( aEngTxt );
912 : : }
913 : 852 : }
914 : :
915 : :
916 : 852 : sal_Bool SmDocShell::SaveAs( SfxMedium& rMedium )
917 : : {
918 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::SaveAs" );
919 : :
920 : 852 : bool bRet = false;
921 : :
922 : : //! apply latest changes if necessary
923 : 852 : UpdateText();
924 : :
925 [ + - ]: 852 : if ( SfxObjectShell::SaveAs( rMedium ) )
926 : : {
927 [ - + ]: 852 : if (!pTree)
928 [ # # ]: 0 : Parse();
929 [ + - ][ - + ]: 852 : if( pTree && !IsFormulaArranged() )
[ - + ]
930 [ # # ]: 0 : ArrangeFormula();
931 : :
932 [ + - ]: 852 : Reference<com::sun::star::frame::XModel> xModel(GetModel());
933 [ + - ]: 852 : SmXMLExportWrapper aEquation(xModel);
934 : 852 : aEquation.SetFlat(sal_False);
935 [ + - ][ + - ]: 852 : bRet = aEquation.Export(rMedium);
936 : : }
937 : 852 : return bRet;
938 : : }
939 : :
940 : 0 : sal_Bool SmDocShell::ConvertTo( SfxMedium &rMedium )
941 : : {
942 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::ConvertTo" );
943 : :
944 : 0 : bool bRet = false;
945 : 0 : const SfxFilter* pFlt = rMedium.GetFilter();
946 [ # # ]: 0 : if( pFlt )
947 : : {
948 [ # # ]: 0 : if( !pTree )
949 : 0 : Parse();
950 [ # # ][ # # ]: 0 : if( pTree && !IsFormulaArranged() )
[ # # ]
951 : 0 : ArrangeFormula();
952 : :
953 : 0 : const String& rFltName = pFlt->GetFilterName();
954 [ # # ]: 0 : if(rFltName.EqualsAscii( STAROFFICE_XML ))
955 : : {
956 [ # # ]: 0 : Reference<com::sun::star::frame::XModel> xModel(GetModel());
957 [ # # ]: 0 : SmXMLExportWrapper aEquation(xModel);
958 : 0 : aEquation.SetFlat(sal_False);
959 [ # # ][ # # ]: 0 : bRet = aEquation.Export(rMedium);
960 : : }
961 [ # # ]: 0 : else if(rFltName.EqualsAscii( MATHML_XML ))
962 : : {
963 [ # # ]: 0 : Reference<com::sun::star::frame::XModel> xModel(GetModel());
964 [ # # ]: 0 : SmXMLExportWrapper aEquation(xModel);
965 : 0 : aEquation.SetFlat(sal_True);
966 [ # # ][ # # ]: 0 : bRet = aEquation.Export(rMedium);
967 : : }
968 [ # # ]: 0 : else if( pFlt->GetFilterName().EqualsAscii("MathType 3.x"))
969 : 0 : bRet = WriteAsMathType3( rMedium );
970 : : }
971 : 0 : return bRet;
972 : : }
973 : :
974 : 126 : bool SmDocShell::writeFormulaOoxml( ::sax_fastparser::FSHelperPtr pSerializer, oox::core::OoxmlVersion version )
975 : : {
976 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::writeFormulaOoxml" );
977 : :
978 [ - + ]: 126 : if( !pTree )
979 [ # # ]: 0 : Parse();
980 [ + - ][ - + ]: 126 : if( pTree && !IsFormulaArranged() )
[ - + ]
981 [ # # ]: 0 : ArrangeFormula();
982 [ + - ]: 126 : SmOoxmlExport aEquation( pTree, version );
983 [ + - ][ + - ]: 126 : return aEquation.ConvertFromStarMath( pSerializer );
[ + - ][ + - ]
984 : : }
985 : :
986 : 87 : void SmDocShell::writeFormulaRtf(OStringBuffer& rBuffer, rtl_TextEncoding nEncoding)
987 : : {
988 [ - + ]: 87 : if (!pTree)
989 [ # # ]: 0 : Parse();
990 [ + - ][ - + ]: 87 : if (pTree && !IsFormulaArranged())
[ - + ]
991 [ # # ]: 0 : ArrangeFormula();
992 [ + - ]: 87 : SmRtfExport aEquation(pTree);
993 [ + - ][ + - ]: 87 : aEquation.ConvertFromStarMath(rBuffer, nEncoding);
994 : 87 : }
995 : :
996 : 426 : void SmDocShell::readFormulaOoxml( oox::formulaimport::XmlStream& stream )
997 : : {
998 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::readFormulaOoxml" );
999 : :
1000 [ + - ]: 426 : SmOoxmlImport aEquation( stream );
1001 [ + - ][ + - ]: 426 : SetText( aEquation.ConvertToStarMath());
[ + - ][ + - ]
1002 : 426 : }
1003 : :
1004 : 1704 : sal_Bool SmDocShell::SaveCompleted( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage )
1005 : : {
1006 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::SaveCompleted" );
1007 : :
1008 [ + - ]: 1704 : if( SfxObjectShell::SaveCompleted( xStorage ))
1009 : 1704 : return true;
1010 : :
1011 : 1704 : return false;
1012 : : }
1013 : :
1014 : :
1015 : 0 : void SmDocShell::Execute(SfxRequest& rReq)
1016 : : {
1017 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::Execute" );
1018 : :
1019 [ # # # # : 0 : switch (rReq.GetSlot())
# # # # #
# # ]
1020 : : {
1021 : : case SID_TEXTMODE:
1022 : : {
1023 [ # # ]: 0 : SmFormat aOldFormat = GetFormat();
1024 [ # # ]: 0 : SmFormat aNewFormat( aOldFormat );
1025 : 0 : aNewFormat.SetTextmode(!aOldFormat.IsTextmode());
1026 : :
1027 [ # # ]: 0 : ::svl::IUndoManager *pTmpUndoMgr = GetUndoManager();
1028 [ # # ]: 0 : if (pTmpUndoMgr)
1029 : : pTmpUndoMgr->AddUndoAction(
1030 [ # # ][ # # ]: 0 : new SmFormatAction(this, aOldFormat, aNewFormat));
[ # # ]
1031 : :
1032 [ # # ]: 0 : SetFormat( aNewFormat );
1033 [ # # ][ # # ]: 0 : Repaint();
[ # # ]
1034 : : }
1035 : 0 : break;
1036 : :
1037 : : case SID_AUTO_REDRAW :
1038 : : {
1039 : 0 : SmModule *pp = SM_MOD();
1040 : 0 : bool bRedraw = pp->GetConfig()->IsAutoRedraw();
1041 : 0 : pp->GetConfig()->SetAutoRedraw(!bRedraw);
1042 : : }
1043 : 0 : break;
1044 : :
1045 : : case SID_LOADSYMBOLS:
1046 : 0 : LoadSymbols();
1047 : 0 : break;
1048 : :
1049 : : case SID_SAVESYMBOLS:
1050 : 0 : SaveSymbols();
1051 : 0 : break;
1052 : :
1053 : : case SID_FONT:
1054 : : {
1055 : : // get device used to retrieve the FontList
1056 [ # # ]: 0 : OutputDevice *pDev = GetPrinter();
1057 [ # # ][ # # ]: 0 : if (!pDev || pDev->GetDevFontCount() == 0)
[ # # ][ # # ]
1058 [ # # ][ # # ]: 0 : pDev = &SM_MOD()->GetDefaultVirtualDev();
1059 : : OSL_ENSURE (pDev, "device for font list missing" );
1060 : :
1061 [ # # ][ # # ]: 0 : SmFontTypeDialog *pFontTypeDialog = new SmFontTypeDialog( NULL, pDev );
1062 : :
1063 [ # # ]: 0 : SmFormat aOldFormat = GetFormat();
1064 [ # # ]: 0 : pFontTypeDialog->ReadFrom( aOldFormat );
1065 [ # # ][ # # ]: 0 : if (pFontTypeDialog->Execute() == RET_OK)
1066 : : {
1067 [ # # ]: 0 : SmFormat aNewFormat( aOldFormat );
1068 : :
1069 [ # # ]: 0 : pFontTypeDialog->WriteTo(aNewFormat);
1070 [ # # ]: 0 : ::svl::IUndoManager *pTmpUndoMgr = GetUndoManager();
1071 [ # # ]: 0 : if (pTmpUndoMgr)
1072 : : pTmpUndoMgr->AddUndoAction(
1073 [ # # ][ # # ]: 0 : new SmFormatAction(this, aOldFormat, aNewFormat));
[ # # ]
1074 : :
1075 [ # # ]: 0 : SetFormat( aNewFormat );
1076 [ # # ][ # # ]: 0 : Repaint();
1077 : : }
1078 [ # # ][ # # ]: 0 : delete pFontTypeDialog;
[ # # ]
1079 : : }
1080 : 0 : break;
1081 : :
1082 : : case SID_FONTSIZE:
1083 : : {
1084 [ # # ][ # # ]: 0 : SmFontSizeDialog *pFontSizeDialog = new SmFontSizeDialog(NULL);
1085 : :
1086 [ # # ]: 0 : SmFormat aOldFormat = GetFormat();
1087 [ # # ]: 0 : pFontSizeDialog->ReadFrom( aOldFormat );
1088 [ # # ][ # # ]: 0 : if (pFontSizeDialog->Execute() == RET_OK)
1089 : : {
1090 [ # # ]: 0 : SmFormat aNewFormat( aOldFormat );
1091 : :
1092 [ # # ]: 0 : pFontSizeDialog->WriteTo(aNewFormat);
1093 : :
1094 [ # # ]: 0 : ::svl::IUndoManager *pTmpUndoMgr = GetUndoManager();
1095 [ # # ]: 0 : if (pTmpUndoMgr)
1096 : : pTmpUndoMgr->AddUndoAction(
1097 [ # # ][ # # ]: 0 : new SmFormatAction(this, aOldFormat, aNewFormat));
[ # # ]
1098 : :
1099 [ # # ]: 0 : SetFormat( aNewFormat );
1100 [ # # ][ # # ]: 0 : Repaint();
1101 : : }
1102 [ # # ][ # # ]: 0 : delete pFontSizeDialog;
[ # # ]
1103 : : }
1104 : 0 : break;
1105 : :
1106 : : case SID_DISTANCE:
1107 : : {
1108 [ # # ][ # # ]: 0 : SmDistanceDialog *pDistanceDialog = new SmDistanceDialog(NULL);
1109 : :
1110 [ # # ]: 0 : SmFormat aOldFormat = GetFormat();
1111 [ # # ]: 0 : pDistanceDialog->ReadFrom( aOldFormat );
1112 [ # # ][ # # ]: 0 : if (pDistanceDialog->Execute() == RET_OK)
1113 : : {
1114 [ # # ]: 0 : SmFormat aNewFormat( aOldFormat );
1115 : :
1116 [ # # ]: 0 : pDistanceDialog->WriteTo(aNewFormat);
1117 : :
1118 [ # # ]: 0 : ::svl::IUndoManager *pTmpUndoMgr = GetUndoManager();
1119 [ # # ]: 0 : if (pTmpUndoMgr)
1120 : : pTmpUndoMgr->AddUndoAction(
1121 [ # # ][ # # ]: 0 : new SmFormatAction(this, aOldFormat, aNewFormat));
[ # # ]
1122 : :
1123 [ # # ]: 0 : SetFormat( aNewFormat );
1124 [ # # ][ # # ]: 0 : Repaint();
1125 : : }
1126 [ # # ][ # # ]: 0 : delete pDistanceDialog;
[ # # ]
1127 : : }
1128 : 0 : break;
1129 : :
1130 : : case SID_ALIGN:
1131 : : {
1132 [ # # ][ # # ]: 0 : SmAlignDialog *pAlignDialog = new SmAlignDialog(NULL);
1133 : :
1134 [ # # ]: 0 : SmFormat aOldFormat = GetFormat();
1135 [ # # ]: 0 : pAlignDialog->ReadFrom( aOldFormat );
1136 [ # # ][ # # ]: 0 : if (pAlignDialog->Execute() == RET_OK)
1137 : : {
1138 [ # # ]: 0 : SmFormat aNewFormat( aOldFormat );
1139 : :
1140 [ # # ]: 0 : pAlignDialog->WriteTo(aNewFormat);
1141 : :
1142 [ # # ]: 0 : SmModule *pp = SM_MOD();
1143 [ # # ][ # # ]: 0 : SmFormat aFmt( pp->GetConfig()->GetStandardFormat() );
[ # # ]
1144 [ # # ]: 0 : pAlignDialog->WriteTo( aFmt );
1145 [ # # ][ # # ]: 0 : pp->GetConfig()->SetStandardFormat( aFmt );
1146 : :
1147 [ # # ]: 0 : ::svl::IUndoManager *pTmpUndoMgr = GetUndoManager();
1148 [ # # ]: 0 : if (pTmpUndoMgr)
1149 : : pTmpUndoMgr->AddUndoAction(
1150 [ # # ][ # # ]: 0 : new SmFormatAction(this, aOldFormat, aNewFormat));
[ # # ]
1151 : :
1152 [ # # ]: 0 : SetFormat( aNewFormat );
1153 [ # # ][ # # ]: 0 : Repaint();
[ # # ]
1154 : : }
1155 [ # # ][ # # ]: 0 : delete pAlignDialog;
[ # # # # ]
1156 : : }
1157 : 0 : break;
1158 : :
1159 : : case SID_TEXT:
1160 : : {
1161 : 0 : const SfxStringItem& rItem = (const SfxStringItem&)rReq.GetArgs()->Get(SID_TEXT);
1162 [ # # ]: 0 : if (GetText() != rItem.GetValue())
1163 : 0 : SetText(rItem.GetValue());
1164 : : }
1165 : 0 : break;
1166 : :
1167 : : case SID_UNDO:
1168 : : case SID_REDO:
1169 : : {
1170 : 0 : ::svl::IUndoManager* pTmpUndoMgr = GetUndoManager();
1171 [ # # ]: 0 : if( pTmpUndoMgr )
1172 : : {
1173 : 0 : sal_uInt16 nId = rReq.GetSlot(), nCnt = 1;
1174 : 0 : const SfxItemSet* pArgs = rReq.GetArgs();
1175 : : const SfxPoolItem* pItem;
1176 [ # # ][ # # ]: 0 : if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( nId, false, &pItem ))
[ # # ][ # # ]
1177 : 0 : nCnt = ((SfxUInt16Item*)pItem)->GetValue();
1178 : :
1179 : : sal_Bool (::svl::IUndoManager:: *fnDo)();
1180 : :
1181 : : sal_uInt16 nCount;
1182 [ # # ]: 0 : if( SID_UNDO == rReq.GetSlot() )
1183 : : {
1184 [ # # ]: 0 : nCount = pTmpUndoMgr->GetUndoActionCount();
1185 : 0 : fnDo = &::svl::IUndoManager::Undo;
1186 : : }
1187 : : else
1188 : : {
1189 [ # # ]: 0 : nCount = pTmpUndoMgr->GetRedoActionCount();
1190 : 0 : fnDo = &::svl::IUndoManager::Redo;
1191 : : }
1192 : :
1193 : : try
1194 : : {
1195 [ # # ][ # # ]: 0 : for( ; nCnt && nCount; --nCnt, --nCount )
[ # # ]
1196 [ # # ][ # # ]: 0 : (pTmpUndoMgr->*fnDo)();
1197 : : }
1198 [ # # ]: 0 : catch( const Exception& )
1199 : : {
1200 : : DBG_UNHANDLED_EXCEPTION();
1201 : : }
1202 : : }
1203 : 0 : Repaint();
1204 : 0 : UpdateText();
1205 : 0 : SfxViewFrame* pFrm = SfxViewFrame::GetFirst( this );
1206 [ # # ]: 0 : while( pFrm )
1207 : : {
1208 : 0 : SfxBindings& rBind = pFrm->GetBindings();
1209 : 0 : rBind.Invalidate(SID_UNDO);
1210 : 0 : rBind.Invalidate(SID_REDO);
1211 : 0 : rBind.Invalidate(SID_REPEAT);
1212 : 0 : rBind.Invalidate(SID_CLEARHISTORY);
1213 : 0 : pFrm = SfxViewFrame::GetNext( *pFrm, this );
1214 : : }
1215 : : }
1216 : 0 : break;
1217 : : }
1218 : :
1219 : 0 : rReq.Done();
1220 : 0 : }
1221 : :
1222 : :
1223 : 45 : void SmDocShell::GetState(SfxItemSet &rSet)
1224 : : {
1225 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::GetState" );
1226 : :
1227 [ + - ]: 45 : SfxWhichIter aIter(rSet);
1228 : :
1229 [ + - ][ + - ]: 111 : for (sal_uInt16 nWh = aIter.FirstWhich(); 0 != nWh; nWh = aIter.NextWhich())
[ + + ]
1230 : : {
1231 [ - - - - : 66 : switch (nWh)
+ + + -
- ]
1232 : : {
1233 : : case SID_TEXTMODE:
1234 [ # # ][ # # ]: 0 : rSet.Put(SfxBoolItem(SID_TEXTMODE, GetFormat().IsTextmode()));
[ # # ]
1235 : 0 : break;
1236 : :
1237 : : case SID_DOCTEMPLATE :
1238 [ # # ]: 0 : rSet.DisableItem(SID_DOCTEMPLATE);
1239 : 0 : break;
1240 : :
1241 : : case SID_AUTO_REDRAW :
1242 : : {
1243 [ # # ]: 0 : SmModule *pp = SM_MOD();
1244 [ # # ][ # # ]: 0 : bool bRedraw = pp->GetConfig()->IsAutoRedraw();
1245 : :
1246 [ # # ][ # # ]: 0 : rSet.Put(SfxBoolItem(SID_AUTO_REDRAW, bRedraw));
[ # # ]
1247 : : }
1248 : 0 : break;
1249 : :
1250 : : case SID_MODIFYSTATUS:
1251 : : {
1252 : 0 : sal_Unicode cMod = ' ';
1253 [ # # ][ # # ]: 0 : if (IsModified())
1254 : 0 : cMod = '*';
1255 [ # # ][ # # ]: 0 : rSet.Put(SfxStringItem(SID_MODIFYSTATUS, rtl::OUString(cMod)));
[ # # ][ # # ]
[ # # ]
1256 : : }
1257 : 0 : break;
1258 : :
1259 : : case SID_TEXT:
1260 [ + - ][ + - ]: 7 : rSet.Put(SfxStringItem(SID_TEXT, GetText()));
[ + - ]
1261 : 7 : break;
1262 : :
1263 : : case SID_GAPHIC_SM:
1264 : : //! very old (pre UNO) and ugly hack to invalidate the SmGraphicWindow.
1265 : : //! If nModifyCount gets changed then the call below will implicitly notify
1266 : : //! SmGraphicController::StateChanged and there the window gets invalidated.
1267 : : //! Thus all the 'nModifyCount++' before invalidating this slot.
1268 [ + - ][ + - ]: 7 : rSet.Put(SfxInt16Item(SID_GAPHIC_SM, nModifyCount));
[ + - ]
1269 : 7 : break;
1270 : :
1271 : : case SID_UNDO:
1272 : : case SID_REDO:
1273 : : {
1274 [ + - ]: 52 : SfxViewFrame* pFrm = SfxViewFrame::GetFirst( this );
1275 [ + - ]: 52 : if( pFrm )
1276 [ + - ]: 52 : pFrm->GetSlotState( nWh, NULL, &rSet );
1277 : : else
1278 [ # # ]: 0 : rSet.DisableItem( nWh );
1279 : : }
1280 : 52 : break;
1281 : :
1282 : : case SID_GETUNDOSTRINGS:
1283 : : case SID_GETREDOSTRINGS:
1284 : : {
1285 [ # # ]: 0 : ::svl::IUndoManager* pTmpUndoMgr = GetUndoManager();
1286 [ # # ]: 0 : if( pTmpUndoMgr )
1287 : : {
1288 : : rtl::OUString(::svl::IUndoManager:: *fnGetComment)( size_t, bool const ) const;
1289 : :
1290 : : sal_uInt16 nCount;
1291 [ # # ]: 0 : if( SID_GETUNDOSTRINGS == nWh )
1292 : : {
1293 [ # # ]: 0 : nCount = pTmpUndoMgr->GetUndoActionCount();
1294 : 0 : fnGetComment = &::svl::IUndoManager::GetUndoActionComment;
1295 : : }
1296 : : else
1297 : : {
1298 [ # # ]: 0 : nCount = pTmpUndoMgr->GetRedoActionCount();
1299 : 0 : fnGetComment = &::svl::IUndoManager::GetRedoActionComment;
1300 : : }
1301 [ # # ]: 0 : if( nCount )
1302 : : {
1303 [ # # ]: 0 : String sList;
1304 [ # # ]: 0 : for( sal_uInt16 n = 0; n < nCount; ++n )
1305 [ # # ][ # # ]: 0 : ( sList += (pTmpUndoMgr->*fnGetComment)( n, ::svl::IUndoManager::TopLevel ) )
[ # # ]
1306 [ # # ]: 0 : += '\n';
1307 : :
1308 [ # # ]: 0 : SfxStringListItem aItem( nWh );
1309 [ # # ]: 0 : aItem.SetString( sList );
1310 [ # # ][ # # ]: 0 : rSet.Put( aItem );
[ # # ]
1311 : : }
1312 : : }
1313 : : else
1314 [ # # ]: 0 : rSet.DisableItem( nWh );
1315 : : }
1316 : 0 : break;
1317 : : }
1318 [ + - ]: 45 : }
1319 : 45 : }
1320 : :
1321 : :
1322 : 0 : ::svl::IUndoManager *SmDocShell::GetUndoManager()
1323 : : {
1324 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::GetUndoManager" );
1325 : :
1326 [ # # ]: 0 : if (!pEditEngine)
1327 : 0 : GetEditEngine();
1328 : 0 : return &pEditEngine->GetUndoManager();
1329 : : }
1330 : :
1331 : :
1332 : 0 : void SmDocShell::SaveSymbols()
1333 : : {
1334 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::SaveSymbols" );
1335 : :
1336 : 0 : SmModule *pp = SM_MOD();
1337 : 0 : pp->GetSymbolManager().Save();
1338 : 0 : }
1339 : :
1340 : :
1341 : 6816 : void SmDocShell::Draw(OutputDevice *pDevice,
1342 : : const JobSetup &,
1343 : : sal_uInt16 /*nAspect*/)
1344 : : {
1345 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::Draw" );
1346 : :
1347 [ + - ][ + - ]: 6816 : pDevice->IntersectClipRegion(GetVisArea());
1348 : 6816 : Point atmppoint;
1349 [ + - ]: 6816 : DrawFormula(*pDevice, atmppoint);
1350 : 6816 : }
1351 : :
1352 : 34 : SfxItemPool& SmDocShell::GetPool() const
1353 : : {
1354 : 34 : return SFX_APP()->GetPool();
1355 : : }
1356 : :
1357 : 1862 : void SmDocShell::SetVisArea(const Rectangle & rVisArea)
1358 : : {
1359 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::SetVisArea" );
1360 : :
1361 : 1862 : Rectangle aNewRect(rVisArea);
1362 : :
1363 : 1862 : aNewRect.SetPos(Point());
1364 : :
1365 [ - + ]: 1862 : if (! aNewRect.Right()) aNewRect.Right() = 2000;
1366 [ - + ]: 1862 : if (! aNewRect.Bottom()) aNewRect.Bottom() = 1000;
1367 : :
1368 [ + - ]: 1862 : bool bIsEnabled = IsEnableSetModified();
1369 [ + + ]: 1862 : if ( bIsEnabled )
1370 [ + - ]: 584 : EnableSetModified( false );
1371 : :
1372 : : //TODO/LATER: it's unclear how this interacts with the SFX code
1373 : : // If outplace editing, then dont resize the OutplaceWindow. But the
1374 : : // ObjectShell has to resize. Bug 56470
1375 : : bool bUnLockFrame;
1376 [ + + ][ + - ]: 1862 : if( GetCreateMode() == SFX_CREATE_MODE_EMBEDDED && !IsInPlaceActive() && GetFrame() )
[ + - ][ + - ]
[ - + ][ - + ]
1377 : : {
1378 [ # # ]: 0 : GetFrame()->LockAdjustPosSizePixel();
1379 : 0 : bUnLockFrame = true;
1380 : : }
1381 : : else
1382 : 1862 : bUnLockFrame = false;
1383 : :
1384 [ + - ]: 1862 : SfxObjectShell::SetVisArea( aNewRect );
1385 : :
1386 [ - + ]: 1862 : if( bUnLockFrame )
1387 [ # # ]: 0 : GetFrame()->UnlockAdjustPosSizePixel();
1388 : :
1389 [ + + ]: 1862 : if ( bIsEnabled )
1390 [ + - ]: 584 : EnableSetModified( bIsEnabled );
1391 : 1862 : }
1392 : :
1393 : :
1394 : 2164 : void SmDocShell::FillClass(SvGlobalName* pClassName,
1395 : : sal_uInt32* pFormat,
1396 : : String* /*pAppName*/,
1397 : : String* pFullTypeName,
1398 : : String* pShortTypeName,
1399 : : sal_Int32 nFileFormat,
1400 : : sal_Bool bTemplate /* = sal_False */) const
1401 : : {
1402 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::FillClass" );
1403 : :
1404 [ - + ]: 2164 : if (nFileFormat == SOFFICE_FILEFORMAT_60 )
1405 : : {
1406 [ # # ]: 0 : *pClassName = SvGlobalName(SO3_SM_CLASSID_60);
1407 : 0 : *pFormat = SOT_FORMATSTR_ID_STARMATH_60;
1408 [ # # ][ # # ]: 0 : *pFullTypeName = String(SmResId(STR_MATH_DOCUMENT_FULLTYPE_CURRENT));
[ # # ]
1409 [ # # ][ # # ]: 0 : *pShortTypeName = String(SmResId(RID_DOCUMENTSTR));
[ # # ]
1410 : : }
1411 [ + - ]: 2164 : else if (nFileFormat == SOFFICE_FILEFORMAT_8 )
1412 : : {
1413 [ + - ]: 2164 : *pClassName = SvGlobalName(SO3_SM_CLASSID_60);
1414 [ - + ]: 2164 : *pFormat = bTemplate ? SOT_FORMATSTR_ID_STARMATH_8_TEMPLATE : SOT_FORMATSTR_ID_STARMATH_8;
1415 [ + - ][ + - ]: 2164 : *pFullTypeName = String(SmResId(STR_MATH_DOCUMENT_FULLTYPE_CURRENT));
[ + - ]
1416 [ + - ][ + - ]: 2164 : *pShortTypeName = String(SmResId(RID_DOCUMENTSTR));
[ + - ]
1417 : : }
1418 : 2164 : }
1419 : :
1420 : 0 : sal_uLong SmDocShell::GetMiscStatus() const
1421 : : {
1422 : 0 : return SfxObjectShell::GetMiscStatus() | SVOBJ_MISCSTATUS_NOTRESIZEABLE
1423 : 0 : | SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE;
1424 : : }
1425 : :
1426 : 5736 : void SmDocShell::SetModified(sal_Bool bModified)
1427 : : {
1428 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::SetModified" );
1429 : :
1430 [ + + ]: 5736 : if( IsEnableSetModified() )
1431 : : {
1432 : 5702 : SfxObjectShell::SetModified( bModified );
1433 [ + - ]: 5702 : Broadcast(SfxSimpleHint(SFX_HINT_DOCCHANGED));
1434 : : }
1435 : 5736 : }
1436 : :
1437 : 0 : bool SmDocShell::WriteAsMathType3( SfxMedium& rMedium )
1438 : : {
1439 : : RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::WriteAsMathType3" );
1440 : :
1441 [ # # ]: 0 : MathType aEquation( aText, pTree );
1442 : :
1443 [ # # ]: 0 : bool bRet = 0 != aEquation.ConvertFromStarMath( rMedium );
1444 [ # # ]: 0 : return bRet;
1445 [ + - ][ + - ]: 30 : }
1446 : :
1447 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|