CWS-TOOLING: integrate CWS tl88
[LibreOffice.git] / starmath / source / document.cxx
blobab1382b9787948fa183a3c229a72def7df275190
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_starmath.hxx"
32 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
33 #include <com/sun/star/lang/Locale.hpp>
34 #include <com/sun/star/uno/Any.h>
36 #include <comphelper/accessibletexthelper.hxx>
37 #include <comphelper/processfactory.hxx>
38 #include <comphelper/storagehelper.hxx>
39 #include <rtl/logfile.hxx>
40 #include <rtl/ustring.hxx>
41 #include <sfx2/app.hxx>
42 #include <sfx2/dispatch.hxx>
43 #include <sfx2/docfile.hxx>
44 #include <sfx2/docfilt.hxx>
45 #include <sfx2/fcontnr.hxx>
46 #include <sfx2/msg.hxx>
47 #include <sfx2/objface.hxx>
48 #include <sfx2/printer.hxx>
49 #include <sfx2/request.hxx>
50 #include <sfx2/viewfrm.hxx>
51 #include <sot/clsids.hxx>
52 #include <sot/exchange.hxx>
53 #include <sot/formats.hxx>
54 #include <sot/storage.hxx>
55 #include <svl/eitem.hxx>
56 #include <svl/fstathelper.hxx>
57 #include <svl/intitem.hxx>
58 #include <svl/itempool.hxx>
59 #include <unotools/lingucfg.hxx>
60 #include <unotools/linguprops.hxx>
61 #include <unotools/pathoptions.hxx>
62 #include <svl/ptitem.hxx>
63 #include <svtools/sfxecode.hxx>
64 #include <svl/slstitm.hxx>
65 #include <svl/smplhint.hxx>
66 #include <svl/stritem.hxx>
67 #include <svtools/transfer.hxx>
68 #include <svl/undo.hxx>
69 #include <svl/urihelper.hxx>
70 #include <svl/whiter.hxx>
71 #include <editeng/editeng.hxx>
72 #include <editeng/editstat.hxx>
73 #include <editeng/eeitem.hxx>
74 #include <editeng/fhgtitem.hxx>
75 #include <editeng/fontitem.hxx>
76 #include <editeng/unolingu.hxx>
77 #include <ucbhelper/content.hxx>
78 #include <vcl/mapmod.hxx>
79 #include <vcl/mapunit.hxx>
80 #include <vcl/msgbox.hxx>
81 #include <sfx2/sfx.hrc>
82 #include <document.hxx>
83 #include <action.hxx>
84 #include <config.hxx>
85 #include <dialog.hxx>
86 #include <format.hxx>
87 #include <smdll.hxx>
88 #include <starmath.hrc>
89 #include <symbol.hxx>
90 #include <toolbox.hxx>
91 #include <unomodel.hxx>
92 #include <utility.hxx>
93 #include <view.hxx>
94 #include "mathtype.hxx"
95 #include "mathmlimport.hxx"
96 #include "mathmlexport.hxx"
97 #include <sfx2/sfxsids.hrc>
98 #include <svx/svxids.hrc>
100 using namespace ::com::sun::star;
101 using namespace ::com::sun::star::accessibility;
102 using namespace ::com::sun::star::lang;
103 using namespace ::com::sun::star::ucb;
104 using namespace ::com::sun::star::uno;
107 #define DOCUMENT_BUFFER_SIZE (USHORT)32768
109 static const char __FAR_DATA pStarMathDoc[] = "StarMathDocument";
111 #define SmDocShell
112 #include "smslots.hxx"
114 ////////////////////////////////////////////////////////////
117 TYPEINIT1( SmDocShell, SfxObjectShell );
119 SFX_IMPL_INTERFACE(SmDocShell, SfxObjectShell, SmResId(0))
121 SFX_POPUPMENU_REGISTRATION(SmResId(RID_VIEWMENU));
122 SFX_POPUPMENU_REGISTRATION(SmResId(RID_COMMANDMENU));
125 SFX_IMPL_OBJECTFACTORY(SmDocShell, SvGlobalName(SO3_SM_CLASSID), SFXOBJECTSHELL_STD_NORMAL, "smath" )
127 void SmDocShell::SFX_NOTIFY(SfxBroadcaster&, const TypeId&,
128 const SfxHint& rHint, const TypeId&)
130 switch (((SfxSimpleHint&)rHint).GetId())
132 case HINT_FORMATCHANGED:
133 SetFormulaArranged(FALSE);
135 nModifyCount++; //! see comment for SID_GAPHIC_SM in SmDocShell::GetState
137 Repaint();
138 break;
142 void SmDocShell::LoadSymbols()
144 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::LoadSymbols" );
146 SmModule *pp = SM_MOD();
147 pp->GetSymbolManager().Load();
151 const String SmDocShell::GetComment() const
153 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::GetComment" );
154 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
155 const_cast<SmDocShell*>(this)->GetModel(), uno::UNO_QUERY_THROW);
156 uno::Reference<document::XDocumentProperties> xDocProps(
157 xDPS->getDocumentProperties());
158 return xDocProps->getDescription();
162 void SmDocShell::SetText(const String& rBuffer)
164 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::SetText" );
166 if (rBuffer != aText)
168 BOOL bIsEnabled = IsEnableSetModified();
169 if( bIsEnabled )
170 EnableSetModified( FALSE );
172 aText = rBuffer;
173 SetFormulaArranged( FALSE );
175 Parse();
176 //Repaint();
178 SmViewShell *pViewSh = SmGetActiveView();
179 if( pViewSh )
181 pViewSh->GetViewFrame()->GetBindings().Invalidate(SID_TEXT);
182 if ( SFX_CREATE_MODE_EMBEDDED == GetCreateMode() )
183 Repaint();
184 else
185 pViewSh->GetGraphicWindow().Invalidate();
188 if ( bIsEnabled )
189 EnableSetModified( bIsEnabled );
190 SetModified(TRUE);
192 // launch accessible event if necessary
193 SmGraphicAccessible *pAcc = pViewSh ? pViewSh->GetGraphicWindow().GetAccessible_Impl() : 0;
194 if (pAcc)
196 Any aOldValue, aNewValue;
197 if ( comphelper::OCommonAccessibleText::implInitTextChangedEvent( aText, rBuffer, aOldValue, aNewValue ) )
199 pAcc->LaunchEvent( AccessibleEventId::TEXT_CHANGED,
200 aOldValue, aNewValue );
204 if ( GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
205 OnDocumentPrinterChanged(0);
209 void SmDocShell::SetFormat(SmFormat& rFormat)
211 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::SetFormat" );
213 aFormat = rFormat;
214 SetFormulaArranged( FALSE );
215 SetModified( TRUE );
217 nModifyCount++; //! see comment for SID_GAPHIC_SM in SmDocShell::GetState
219 // don't use SmGetActiveView since the view shell might not be active (0 pointer)
220 // if for example the Basic Macro dialog currently has the focus. Thus:
221 SfxViewFrame* pFrm = SfxViewFrame::GetFirst( this );
222 while (pFrm)
224 pFrm->GetBindings().Invalidate(SID_GAPHIC_SM);
225 pFrm = SfxViewFrame::GetNext( *pFrm, this );
229 String SmDocShell::GetAccessibleText()
231 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::GetAccessibleText" );
233 if (!IsFormulaArranged())
234 ArrangeFormula();
235 if (0 == aAccText.Len())
237 DBG_ASSERT( pTree, "Tree missing" );
238 if (pTree)
239 pTree->GetAccessibleText( aAccText );
241 return aAccText;
244 void SmDocShell::Parse()
246 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::Parse" );
248 if (pTree)
249 delete pTree;
250 ReplaceBadChars();
251 pTree = aInterpreter.Parse(aText);
252 nModifyCount++; //! see comment for SID_GAPHIC_SM in SmDocShell::GetState
253 SetFormulaArranged( FALSE );
257 void SmDocShell::ArrangeFormula()
259 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::ArrangeFormula" );
261 if (IsFormulaArranged())
262 return;
264 //! Nur f�r die Dauer der Existenz dieses Objekts sind am Drucker die
265 //! richtigen Einstellungen garantiert.
266 SmPrinterAccess aPrtAcc(*this);
267 // OutputDevice *pOutDev = aPrtAcc.GetPrinter();
268 OutputDevice* pOutDev = aPrtAcc.GetRefDev();
270 if (!pOutDev)
272 #if OSL_DEBUG_LEVEL > 1
273 DBG_ERROR("!! SmDocShell::ArrangeFormula: reference device missing !!");
274 #endif
277 // falls n�tig ein anderes OutputDevice holen f�r das formatiert wird
278 if (!pOutDev)
280 SmViewShell *pView = SmGetActiveView();
281 if (pView)
282 pOutDev = &pView->GetGraphicWindow();
283 else
285 pOutDev = &SM_MOD()->GetDefaultVirtualDev();
286 pOutDev->SetMapMode( MapMode(MAP_100TH_MM) );
289 DBG_ASSERT(pOutDev->GetMapMode().GetMapUnit() == MAP_100TH_MM,
290 "Sm : falscher MapMode");
292 const SmFormat &rFormat = GetFormat();
293 pTree->Prepare(rFormat, *this);
295 // format/draw formulas always from left to right,
296 // and numbers should not be converted
297 ULONG nLayoutMode = pOutDev->GetLayoutMode();
298 pOutDev->SetLayoutMode( TEXT_LAYOUT_BIDI_LTR );
299 INT16 nDigitLang = pOutDev->GetDigitLanguage();
300 pOutDev->SetDigitLanguage( LANGUAGE_ENGLISH );
302 pTree->Arrange(*pOutDev, rFormat);
304 pOutDev->SetLayoutMode( nLayoutMode );
305 pOutDev->SetDigitLanguage( nDigitLang );
307 SetFormulaArranged(TRUE);
309 // invalidate accessible text
310 aAccText = String();
314 void SetEditEngineDefaultFonts(
315 EditEngine &/*rEditEngine*/,
316 SfxItemPool &rEditEngineItemPool )
319 // set fonts to be used
321 SvtLinguOptions aOpt;
322 SvtLinguConfig().GetOptions( aOpt );
324 struct FontDta {
325 INT16 nFallbackLang;
326 INT16 nLang;
327 USHORT nFontType;
328 USHORT nFontInfoId;
329 } aTable[3] =
331 // info to get western font to be used
332 { LANGUAGE_ENGLISH_US, LANGUAGE_NONE,
333 DEFAULTFONT_FIXED, EE_CHAR_FONTINFO },
334 // info to get CJK font to be used
335 { LANGUAGE_JAPANESE, LANGUAGE_NONE,
336 DEFAULTFONT_CJK_TEXT, EE_CHAR_FONTINFO_CJK },
337 // info to get CTL font to be used
338 { LANGUAGE_ARABIC_SAUDI_ARABIA, LANGUAGE_NONE,
339 DEFAULTFONT_CTL_TEXT, EE_CHAR_FONTINFO_CTL }
341 aTable[0].nLang = aOpt.nDefaultLanguage;
342 aTable[1].nLang = aOpt.nDefaultLanguage_CJK;
343 aTable[2].nLang = aOpt.nDefaultLanguage_CTL;
345 for (int i = 0; i < 3; ++i)
347 const FontDta &rFntDta = aTable[i];
348 LanguageType nLang = (LANGUAGE_NONE == rFntDta.nLang) ?
349 rFntDta.nFallbackLang : rFntDta.nLang;
350 Font aFont = Application::GetDefaultDevice()->GetDefaultFont(
351 rFntDta.nFontType, nLang, DEFAULTFONT_FLAGS_ONLYONE );
352 #ifdef DEBUG_TL
353 ByteString aFntName( aFont.GetName(), 1 );
354 int eFntFamily = aFont.GetFamily();
355 ByteString aFntStyleName( aFont.GetStyleName(), 1 );
356 int ePitch = aFont.GetPitch();
357 int eCharSet = aFont.GetCharSet();
358 fprintf(stderr, "\nFontName %s \n", aFntName.GetBuffer() );
359 fprintf(stderr, "StyleName %s \n", aFntStyleName.GetBuffer() );
360 fprintf(stderr, "eFntFamily %d \n", eFntFamily );
361 fprintf(stderr, "ePitch %d \n", ePitch );
362 fprintf(stderr, "eCharSet %d \n", eCharSet );
363 #endif
364 rEditEngineItemPool.SetPoolDefaultItem(
365 SvxFontItem( aFont.GetFamily(), aFont.GetName(),
366 aFont.GetStyleName(), aFont.GetPitch(), aFont.GetCharSet(),
367 rFntDta.nFontInfoId ) );
370 // set font heights
371 SvxFontHeightItem aFontHeigt(
372 Application::GetDefaultDevice()->LogicToPixel(
373 Size( 0, 11 ), MapMode( MAP_POINT ) ).Height(), 100,
374 EE_CHAR_FONTHEIGHT );
375 rEditEngineItemPool.SetPoolDefaultItem( aFontHeigt );
376 aFontHeigt.SetWhich( EE_CHAR_FONTHEIGHT_CJK );
377 rEditEngineItemPool.SetPoolDefaultItem( aFontHeigt );
378 aFontHeigt.SetWhich( EE_CHAR_FONTHEIGHT_CTL );
379 rEditEngineItemPool.SetPoolDefaultItem( aFontHeigt );
383 EditEngine& SmDocShell::GetEditEngine()
385 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::GetEditEngine" );
387 if (!pEditEngine)
390 //! see also SmEditWindow::DataChanged !
393 pEditEngineItemPool = EditEngine::CreatePool();
395 SetEditEngineDefaultFonts( *pEditEngine, *pEditEngineItemPool );
397 pEditEngine = new EditEngine( pEditEngineItemPool );
399 pEditEngine->EnableUndo( TRUE );
400 pEditEngine->SetDefTab( USHORT(
401 Application::GetDefaultDevice()->GetTextWidth( C2S("XXXX") ) ) );
403 pEditEngine->SetControlWord(
404 (pEditEngine->GetControlWord() | EE_CNTRL_AUTOINDENTING) &
405 (~EE_CNTRL_UNDOATTRIBS) &
406 (~EE_CNTRL_PASTESPECIAL) );
408 pEditEngine->SetWordDelimiters( C2S(" .=+-*/(){}[];\"" ) );
409 pEditEngine->SetRefMapMode( MAP_PIXEL );
411 pEditEngine->SetPaperSize( Size( 800, 0 ) );
413 pEditEngine->EraseVirtualDevice();
415 // set initial text if the document already has some...
416 // (may be the case when reloading a doc)
417 String aTxt( GetText() );
418 if (aTxt.Len())
419 pEditEngine->SetText( aTxt );
421 pEditEngine->ClearModifyFlag();
423 // forces new settings to be used if the itempool was modified
424 // after cthe creation of the EditEngine
425 //pEditEngine->Clear(); //#77957 incorrect font size
427 return *pEditEngine;
431 SfxItemPool& SmDocShell::GetEditEngineItemPool()
433 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::GetEditEngineItemPool" );
435 if (!pEditEngineItemPool)
436 GetEditEngine();
437 DBG_ASSERT( pEditEngineItemPool, "EditEngineItemPool missing" );
438 return *pEditEngineItemPool;
442 void SmDocShell::Draw(OutputDevice &rDev, Point &rPosition)
444 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::Draw" );
446 if (!pTree)
447 Parse();
448 DBG_ASSERT(pTree, "Sm : NULL pointer");
450 if (!IsFormulaArranged())
451 ArrangeFormula();
453 //Problem: Was passiert mit dem WYSIWYG? Wir haben waehrend wir inplace aktiv
454 //sind kein Referenzdevice und sind auch nicht darauf ausgerichtet. Es kann
455 //also jetzt eine Differenz zwischen der VisArea (spricht die Groesse im Client)
456 //und der jetzt vorliegenden Groese geben.
457 //Idee: Die Differenz koennte, zumindest behelfsmaessig, mit SmNod::SetSize
458 //angepasst werden.
460 rPosition.X() += aFormat.GetDistance( DIS_LEFTSPACE );
461 rPosition.Y() += aFormat.GetDistance( DIS_TOPSPACE );
463 //! in case of high contrast-mode (accessibility option!)
464 //! the draw mode needs to be set to default, because when imbedding
465 //! Math for example in Calc in "a over b" the fraction bar may not
466 //! be visible else. More generally: the FillColor may have been changed.
467 ULONG nOldDrawMode = DRAWMODE_DEFAULT;
468 BOOL bRestoreDrawMode = FALSE;
469 if (OUTDEV_WINDOW == rDev.GetOutDevType() &&
470 ((Window &) rDev).GetSettings().GetStyleSettings().GetHighContrastMode())
472 nOldDrawMode = rDev.GetDrawMode();
473 rDev.SetDrawMode( DRAWMODE_DEFAULT );
474 bRestoreDrawMode = TRUE;
477 // format/draw formulas always from left to right
478 // and numbers should not be converted
479 ULONG nLayoutMode = rDev.GetLayoutMode();
480 rDev.SetLayoutMode( TEXT_LAYOUT_BIDI_LTR );
481 INT16 nDigitLang = rDev.GetDigitLanguage();
482 rDev.SetDigitLanguage( LANGUAGE_ENGLISH );
484 pTree->Draw(rDev, rPosition);
486 rDev.SetLayoutMode( nLayoutMode );
487 rDev.SetDigitLanguage( nDigitLang );
489 if (bRestoreDrawMode)
490 rDev.SetDrawMode( nOldDrawMode );
495 Size SmDocShell::GetSize()
497 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::GetSize" );
499 Size aRet;
501 if (!pTree)
502 Parse();
504 if (pTree)
506 if (!IsFormulaArranged())
507 ArrangeFormula();
508 aRet = pTree->GetSize();
510 if ( !aRet.Width() )
511 aRet.Width() = 2000;
512 else
513 aRet.Width() += aFormat.GetDistance( DIS_LEFTSPACE ) +
514 aFormat.GetDistance( DIS_RIGHTSPACE );
515 if ( !aRet.Height() )
516 aRet.Height() = 1000;
517 else
518 aRet.Height() += aFormat.GetDistance( DIS_TOPSPACE ) +
519 aFormat.GetDistance( DIS_BOTTOMSPACE );
522 return aRet;
525 ////////////////////////////////////////
527 SmPrinterAccess::SmPrinterAccess( SmDocShell &rDocShell )
529 if ( 0 != (pPrinter = rDocShell.GetPrt()) )
531 pPrinter->Push( PUSH_MAPMODE );
532 if ( SFX_CREATE_MODE_EMBEDDED == rDocShell.GetCreateMode() )
534 // if it is an embedded object (without it's own printer)
535 // we change the MapMode temporarily.
536 //!If it is a document with it's own printer the MapMode should
537 //!be set correct (once) elsewhere(!), in order to avoid numerous
538 //!superfluous pushing and poping of the MapMode when using
539 //!this class.
541 const MapUnit eOld = pPrinter->GetMapMode().GetMapUnit();
542 if ( MAP_100TH_MM != eOld )
544 MapMode aMap( pPrinter->GetMapMode() );
545 aMap.SetMapUnit( MAP_100TH_MM );
546 Point aTmp( aMap.GetOrigin() );
547 aTmp.X() = OutputDevice::LogicToLogic( aTmp.X(), eOld, MAP_100TH_MM );
548 aTmp.Y() = OutputDevice::LogicToLogic( aTmp.Y(), eOld, MAP_100TH_MM );
549 aMap.SetOrigin( aTmp );
550 pPrinter->SetMapMode( aMap );
554 if ( 0 != (pRefDev = rDocShell.GetRefDev()) && pPrinter != pRefDev )
556 pRefDev->Push( PUSH_MAPMODE );
557 if ( SFX_CREATE_MODE_EMBEDDED == rDocShell.GetCreateMode() )
559 // if it is an embedded object (without it's own printer)
560 // we change the MapMode temporarily.
561 //!If it is a document with it's own printer the MapMode should
562 //!be set correct (once) elsewhere(!), in order to avoid numerous
563 //!superfluous pushing and poping of the MapMode when using
564 //!this class.
566 const MapUnit eOld = pRefDev->GetMapMode().GetMapUnit();
567 if ( MAP_100TH_MM != eOld )
569 MapMode aMap( pRefDev->GetMapMode() );
570 aMap.SetMapUnit( MAP_100TH_MM );
571 Point aTmp( aMap.GetOrigin() );
572 aTmp.X() = OutputDevice::LogicToLogic( aTmp.X(), eOld, MAP_100TH_MM );
573 aTmp.Y() = OutputDevice::LogicToLogic( aTmp.Y(), eOld, MAP_100TH_MM );
574 aMap.SetOrigin( aTmp );
575 pRefDev->SetMapMode( aMap );
581 SmPrinterAccess::~SmPrinterAccess()
583 if ( pPrinter )
584 pPrinter->Pop();
585 if ( pRefDev && pRefDev != pPrinter )
586 pRefDev->Pop();
589 ////////////////////////////////////////
591 Printer* SmDocShell::GetPrt()
593 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::GetPrt" );
595 if ( SFX_CREATE_MODE_EMBEDDED == GetCreateMode() )
597 //Normalerweise wird der Printer vom Server besorgt. Wenn dieser aber
598 //keinen liefert (weil etwa noch keine connection da ist), kann es
599 //dennoch sein, dass wir den Printer kennen, denn dieser wird in
600 //OnDocumentPrinterChanged vom Server durchgereicht und dann temporaer
601 //festgehalten.
602 Printer *pPrt = GetDocumentPrinter();
603 if ( !pPrt && pTmpPrinter )
604 pPrt = pTmpPrinter;
605 return pPrt;
607 else if ( !pPrinter )
609 SfxItemSet *pOptions =
610 new SfxItemSet(GetPool(),
611 SID_PRINTSIZE, SID_PRINTSIZE,
612 SID_PRINTZOOM, SID_PRINTZOOM,
613 SID_PRINTTITLE, SID_PRINTTITLE,
614 SID_PRINTTEXT, SID_PRINTTEXT,
615 SID_PRINTFRAME, SID_PRINTFRAME,
616 SID_NO_RIGHT_SPACES, SID_NO_RIGHT_SPACES,
619 SmModule *pp = SM_MOD();
620 pp->GetConfig()->ConfigToItemSet(*pOptions);
621 pPrinter = new SfxPrinter(pOptions);
622 pPrinter->SetMapMode( MapMode(MAP_100TH_MM) );
624 return pPrinter;
627 OutputDevice* SmDocShell::GetRefDev()
629 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::GetRefDev" );
631 if ( SFX_CREATE_MODE_EMBEDDED == GetCreateMode() )
633 OutputDevice* pOutDev = GetDocumentRefDev();
634 if ( pOutDev )
635 return pOutDev;
638 return GetPrt();
642 void SmDocShell::SetPrinter( SfxPrinter *pNew )
644 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::SetPrinter" );
646 delete pPrinter;
647 pPrinter = pNew; //Eigentumsuebergang!
648 pPrinter->SetMapMode( MapMode(MAP_100TH_MM) );
649 SetFormulaArranged(FALSE);
650 Repaint();
653 void SmDocShell::OnDocumentPrinterChanged( Printer *pPrt )
655 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::OnDocumentPrinterChanged" );
657 pTmpPrinter = pPrt;
658 SetFormulaArranged(FALSE);
659 Size aOldSize = GetVisArea().GetSize();
660 Repaint();
661 if( aOldSize != GetVisArea().GetSize() && aText.Len() )
662 SetModified( TRUE );
663 pTmpPrinter = 0;
666 void SmDocShell::Repaint()
668 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::Repaint" );
670 BOOL bIsEnabled = IsEnableSetModified();
671 if ( bIsEnabled )
672 EnableSetModified( FALSE );
674 SetFormulaArranged( FALSE );
676 Size aVisSize = GetSize();
677 SetVisAreaSize( aVisSize );
678 SmViewShell *pViewSh = SmGetActiveView();
679 if (pViewSh)
680 pViewSh->GetGraphicWindow().Invalidate();
682 if ( bIsEnabled )
683 EnableSetModified( bIsEnabled );
687 SmDocShell::SmDocShell( const sal_uInt64 i_nSfxCreationFlags ) :
688 SfxObjectShell( i_nSfxCreationFlags ),
689 pTree ( 0 ),
690 pEditEngineItemPool ( 0 ),
691 pEditEngine ( 0 ),
692 pPrinter ( 0 ),
693 pTmpPrinter ( 0 ),
694 nModifyCount ( 0 ),
695 bIsFormulaArranged ( FALSE )
697 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::SmDocShell" );
699 SetPool(&SFX_APP()->GetPool());
701 SmModule *pp = SM_MOD();
702 aFormat = pp->GetConfig()->GetStandardFormat();
704 StartListening(aFormat);
705 StartListening(*pp->GetConfig());
707 SetBaseModel( new SmModel(this) );
712 SmDocShell::~SmDocShell()
714 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::~SmDocShell" );
716 SmModule *pp = SM_MOD();
718 EndListening(aFormat);
719 EndListening(*pp->GetConfig());
721 delete pEditEngine;
722 SfxItemPool::Free(pEditEngineItemPool);
723 delete pTree;
724 delete pPrinter;
728 BOOL SmDocShell::SetData( const String& rData )
730 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::SetData" );
732 SetText( rData );
733 return TRUE;
737 BOOL SmDocShell::ConvertFrom(SfxMedium &rMedium)
739 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::ConvertFrom" );
741 BOOL bSuccess = FALSE;
742 const String& rFltName = rMedium.GetFilter()->GetFilterName();
744 DBG_ASSERT( !rFltName.EqualsAscii( STAROFFICE_XML ), "Wrong filter!");
746 if ( rFltName.EqualsAscii( MATHML_XML ) )
748 if (pTree)
750 delete pTree;
751 pTree = 0;
753 Reference<com::sun::star::frame::XModel> xModel(GetModel());
754 SmXMLImportWrapper aEquation(xModel);
755 bSuccess = 0 == aEquation.Import(rMedium);
757 else
759 SvStream *pStream = rMedium.GetInStream();
760 if ( pStream )
762 if ( SotStorage::IsStorageFile( pStream ) )
764 SvStorageRef aStorage = new SotStorage( pStream, FALSE );
765 if ( aStorage->IsStream( C2S( "Equation Native" ) ) )
767 // is this a MathType Storage?
768 MathType aEquation( aText );
769 if ( TRUE == (bSuccess = (1 == aEquation.Parse( aStorage )) ))
770 Parse();
773 else
775 //bSuccess = ImportSM20File( pStream );
780 if ( GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
782 //???OnDocumentPrinterChanged(0);
783 SetFormulaArranged( FALSE );
784 Repaint();
787 FinishedLoading( SFX_LOADED_ALL );
788 return bSuccess;
792 BOOL SmDocShell::InitNew( const uno::Reference < embed::XStorage >& xStorage )
794 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::InitNew" );
796 BOOL bRet = FALSE;
797 if ( SfxObjectShell::InitNew( xStorage ) )
799 bRet = TRUE;
800 SetVisArea(Rectangle(Point(0, 0), Size(2000, 1000)));
802 return bRet;
806 BOOL SmDocShell::Load( SfxMedium& rMedium )
808 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::Load" );
810 BOOL bRet = FALSE;
811 if( SfxObjectShell::Load( rMedium ))
813 uno::Reference < embed::XStorage > xStorage = GetMedium()->GetStorage();
814 uno::Reference < container::XNameAccess > xAccess (xStorage, uno::UNO_QUERY);
815 if (
817 xAccess->hasByName( C2S( "content.xml" ) ) &&
818 xStorage->isStreamElement( C2S( "content.xml" ) )
819 ) ||
821 xAccess->hasByName( C2S( "Content.xml" ) ) &&
822 xStorage->isStreamElement( C2S( "Content.xml" ) )
826 // is this a fabulous math package ?
827 Reference<com::sun::star::frame::XModel> xModel(GetModel());
828 SmXMLImportWrapper aEquation(xModel);
829 ULONG nError = aEquation.Import(rMedium);
830 bRet = 0 == nError;
831 SetError( nError, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
835 if ( GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
837 //???OnDocumentPrinterChanged(0);
838 SetFormulaArranged( FALSE );
839 Repaint();
842 FinishedLoading( SFX_LOADED_ALL );
843 return bRet;
846 //------------------------------------------------------------------
848 BOOL SmDocShell::Save()
850 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::Save" );
852 //! apply latest changes if necessary
853 UpdateText();
855 if ( SfxObjectShell::Save() )
857 if (!pTree)
858 Parse();
859 if( pTree && !IsFormulaArranged() )
860 ArrangeFormula();
862 Reference<com::sun::star::frame::XModel> xModel(GetModel());
863 SmXMLExportWrapper aEquation(xModel);
864 aEquation.SetFlat(sal_False);
865 return aEquation.Export(*GetMedium());
868 return FALSE;
872 * replace bad characters that can not be saved. (#i74144)
873 * */
874 sal_Bool SmDocShell::ReplaceBadChars()
876 sal_Bool bReplace = sal_False;
877 if (pEditEngine)
879 String aEngTxt( pEditEngine->GetText( LINEEND_LF ) );
880 const sal_Unicode *pEngTxt = aEngTxt.GetBuffer();
881 xub_StrLen nLen = aEngTxt.Len();
882 for (xub_StrLen i = 0; i < nLen && !bReplace; ++i)
884 const sal_Unicode c = *pEngTxt++;
885 if (c < ' ' && c != '\r' && c != '\n' && c != '\t')
886 bReplace = sal_True;
888 if (bReplace)
890 sal_Unicode *pChgTxt = aEngTxt.GetBufferAccess();
891 for (xub_StrLen i = 0; i < nLen; ++i)
893 sal_Unicode &rc = *pChgTxt++;
894 if (rc < ' ' && rc != '\r' && rc != '\n' && rc != '\t')
895 rc = ' ';
897 aEngTxt.ReleaseBufferAccess( nLen );
899 aText = aEngTxt;
902 return bReplace;
906 void SmDocShell::UpdateText()
908 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::UpdateText" );
910 if (pEditEngine && pEditEngine->IsModified())
912 String aEngTxt( pEditEngine->GetText( LINEEND_LF ) );
913 if (GetText() != aEngTxt)
914 SetText( aEngTxt );
919 BOOL SmDocShell::SaveAs( SfxMedium& rMedium )
921 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::SaveAs" );
923 BOOL bRet = FALSE;
925 //! apply latest changes if necessary
926 UpdateText();
928 if ( SfxObjectShell::SaveAs( rMedium ) )
930 if (!pTree)
931 Parse();
932 if( pTree && !IsFormulaArranged() )
933 ArrangeFormula();
935 Reference<com::sun::star::frame::XModel> xModel(GetModel());
936 SmXMLExportWrapper aEquation(xModel);
937 aEquation.SetFlat(sal_False);
938 bRet = aEquation.Export(rMedium);
940 return bRet;
943 BOOL SmDocShell::ConvertTo( SfxMedium &rMedium )
945 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::ConvertTo" );
947 BOOL bRet = FALSE;
948 const SfxFilter* pFlt = rMedium.GetFilter();
949 if( pFlt )
951 if( !pTree )
952 Parse();
953 if( pTree && !IsFormulaArranged() )
954 ArrangeFormula();
956 const String& rFltName = pFlt->GetFilterName();
957 if(rFltName.EqualsAscii( STAROFFICE_XML ))
959 Reference<com::sun::star::frame::XModel> xModel(GetModel());
960 SmXMLExportWrapper aEquation(xModel);
961 aEquation.SetFlat(sal_False);
962 bRet = aEquation.Export(rMedium);
964 else if(rFltName.EqualsAscii( MATHML_XML ))
966 Reference<com::sun::star::frame::XModel> xModel(GetModel());
967 SmXMLExportWrapper aEquation(xModel);
968 aEquation.SetFlat(sal_True);
969 bRet = aEquation.Export(rMedium);
971 else if( pFlt->GetFilterName().EqualsAscii("MathType 3.x"))
972 bRet = WriteAsMathType3( rMedium );
974 return bRet;
977 BOOL SmDocShell::SaveCompleted( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage )
979 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::SaveCompleted" );
981 if( SfxObjectShell::SaveCompleted( xStorage ))
982 return TRUE;
984 return FALSE;
988 void SmDocShell::Execute(SfxRequest& rReq)
990 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::Execute" );
992 switch (rReq.GetSlot())
994 case SID_TEXTMODE:
996 SmFormat aOldFormat = GetFormat();
997 SmFormat aNewFormat( aOldFormat );
998 aNewFormat.SetTextmode(!aOldFormat.IsTextmode());
1000 SfxUndoManager *pTmpUndoMgr = GetUndoManager();
1001 if (pTmpUndoMgr)
1002 pTmpUndoMgr->AddUndoAction(
1003 new SmFormatAction(this, aOldFormat, aNewFormat));
1005 SetFormat( aNewFormat );
1006 Repaint();
1008 break;
1010 case SID_AUTO_REDRAW :
1012 SmModule *pp = SM_MOD();
1013 BOOL bRedraw = pp->GetConfig()->IsAutoRedraw();
1014 pp->GetConfig()->SetAutoRedraw(!bRedraw);
1016 break;
1018 case SID_LOADSYMBOLS:
1019 LoadSymbols();
1020 break;
1022 case SID_SAVESYMBOLS:
1023 SaveSymbols();
1024 break;
1026 case SID_FONT:
1028 // get device used to retrieve the FontList
1029 OutputDevice *pDev = GetPrinter();
1030 if (!pDev || pDev->GetDevFontCount() == 0)
1031 pDev = &SM_MOD()->GetDefaultVirtualDev();
1032 DBG_ASSERT (pDev, "device for font list missing" );
1034 SmFontTypeDialog *pFontTypeDialog = new SmFontTypeDialog( NULL, pDev );
1036 SmFormat aOldFormat = GetFormat();
1037 pFontTypeDialog->ReadFrom( aOldFormat );
1038 if (pFontTypeDialog->Execute() == RET_OK)
1040 SmFormat aNewFormat( aOldFormat );
1042 pFontTypeDialog->WriteTo(aNewFormat);
1043 SfxUndoManager *pTmpUndoMgr = GetUndoManager();
1044 if (pTmpUndoMgr)
1045 pTmpUndoMgr->AddUndoAction(
1046 new SmFormatAction(this, aOldFormat, aNewFormat));
1048 SetFormat( aNewFormat );
1049 Repaint();
1051 delete pFontTypeDialog;
1053 break;
1055 case SID_FONTSIZE:
1057 SmFontSizeDialog *pFontSizeDialog = new SmFontSizeDialog(NULL);
1059 SmFormat aOldFormat = GetFormat();
1060 pFontSizeDialog->ReadFrom( aOldFormat );
1061 if (pFontSizeDialog->Execute() == RET_OK)
1063 SmFormat aNewFormat( aOldFormat );
1065 pFontSizeDialog->WriteTo(aNewFormat);
1067 SfxUndoManager *pTmpUndoMgr = GetUndoManager();
1068 if (pTmpUndoMgr)
1069 pTmpUndoMgr->AddUndoAction(
1070 new SmFormatAction(this, aOldFormat, aNewFormat));
1072 SetFormat( aNewFormat );
1073 Repaint();
1075 delete pFontSizeDialog;
1077 break;
1079 case SID_DISTANCE:
1081 SmDistanceDialog *pDistanceDialog = new SmDistanceDialog(NULL);
1083 SmFormat aOldFormat = GetFormat();
1084 pDistanceDialog->ReadFrom( aOldFormat );
1085 if (pDistanceDialog->Execute() == RET_OK)
1087 SmFormat aNewFormat( aOldFormat );
1089 pDistanceDialog->WriteTo(aNewFormat);
1091 SfxUndoManager *pTmpUndoMgr = GetUndoManager();
1092 if (pTmpUndoMgr)
1093 pTmpUndoMgr->AddUndoAction(
1094 new SmFormatAction(this, aOldFormat, aNewFormat));
1096 SetFormat( aNewFormat );
1097 Repaint();
1099 delete pDistanceDialog;
1101 break;
1103 case SID_ALIGN:
1105 SmAlignDialog *pAlignDialog = new SmAlignDialog(NULL);
1107 SmFormat aOldFormat = GetFormat();
1108 pAlignDialog->ReadFrom( aOldFormat );
1109 if (pAlignDialog->Execute() == RET_OK)
1111 SmFormat aNewFormat( aOldFormat );
1113 pAlignDialog->WriteTo(aNewFormat);
1115 SmModule *pp = SM_MOD();
1116 SmFormat aFmt( pp->GetConfig()->GetStandardFormat() );
1117 pAlignDialog->WriteTo( aFmt );
1118 pp->GetConfig()->SetStandardFormat( aFmt );
1120 SfxUndoManager *pTmpUndoMgr = GetUndoManager();
1121 if (pTmpUndoMgr)
1122 pTmpUndoMgr->AddUndoAction(
1123 new SmFormatAction(this, aOldFormat, aNewFormat));
1125 SetFormat( aNewFormat );
1126 Repaint();
1128 delete pAlignDialog;
1130 break;
1132 case SID_TEXT:
1134 const SfxStringItem& rItem = (const SfxStringItem&)rReq.GetArgs()->Get(SID_TEXT);
1135 if (GetText() != rItem.GetValue())
1136 SetText(rItem.GetValue());
1138 break;
1140 case SID_UNDO:
1141 case SID_REDO:
1143 SfxUndoManager* pTmpUndoMgr = GetUndoManager();
1144 if( pTmpUndoMgr )
1146 USHORT nId = rReq.GetSlot(), nCnt = 1;
1147 const SfxItemSet* pArgs = rReq.GetArgs();
1148 const SfxPoolItem* pItem;
1149 if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( nId, FALSE, &pItem ))
1150 nCnt = ((SfxUInt16Item*)pItem)->GetValue();
1152 BOOL (SfxUndoManager:: *fnDo)( USHORT );
1154 sal_uInt16 nCount;
1155 if( SID_UNDO == rReq.GetSlot() )
1157 nCount = pTmpUndoMgr->GetUndoActionCount();
1158 fnDo = &SfxUndoManager::Undo;
1160 else
1162 nCount = pTmpUndoMgr->GetRedoActionCount();
1163 fnDo = &SfxUndoManager::Redo;
1166 for( ; nCnt && nCount; --nCnt, --nCount )
1167 (pTmpUndoMgr->*fnDo)( 0 );
1169 Repaint();
1170 SfxViewFrame* pFrm = SfxViewFrame::GetFirst( this );
1171 while( pFrm )
1173 SfxBindings& rBind = pFrm->GetBindings();
1174 rBind.Invalidate(SID_UNDO);
1175 rBind.Invalidate(SID_REDO);
1176 rBind.Invalidate(SID_REPEAT);
1177 rBind.Invalidate(SID_CLEARHISTORY);
1178 pFrm = SfxViewFrame::GetNext( *pFrm, this );
1181 break;
1184 rReq.Done();
1188 void SmDocShell::GetState(SfxItemSet &rSet)
1190 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::GetState" );
1192 SfxWhichIter aIter(rSet);
1194 for (USHORT nWh = aIter.FirstWhich(); 0 != nWh; nWh = aIter.NextWhich())
1196 switch (nWh)
1198 case SID_TEXTMODE:
1199 rSet.Put(SfxBoolItem(SID_TEXTMODE, GetFormat().IsTextmode()));
1200 break;
1202 case SID_DOCTEMPLATE :
1203 rSet.DisableItem(SID_DOCTEMPLATE);
1204 break;
1206 case SID_AUTO_REDRAW :
1208 SmModule *pp = SM_MOD();
1209 BOOL bRedraw = pp->GetConfig()->IsAutoRedraw();
1211 rSet.Put(SfxBoolItem(SID_AUTO_REDRAW, bRedraw));
1213 break;
1215 case SID_MODIFYSTATUS:
1217 sal_Unicode cMod = ' ';
1218 if (IsModified())
1219 cMod = '*';
1220 rSet.Put(SfxStringItem(SID_MODIFYSTATUS, String(cMod)));
1222 break;
1224 case SID_TEXT:
1225 rSet.Put(SfxStringItem(SID_TEXT, GetText()));
1226 break;
1228 case SID_GAPHIC_SM:
1229 //! very old (pre UNO) and ugly hack to invalidate the SmGraphicWindow.
1230 //! If nModifyCount gets changed then the call below will implicitly notify
1231 //! SmGraphicController::StateChanged and there the window gets invalidated.
1232 //! Thus all the 'nModifyCount++' before invalidating this slot.
1233 rSet.Put(SfxInt16Item(SID_GAPHIC_SM, nModifyCount));
1234 break;
1236 case SID_UNDO:
1237 case SID_REDO:
1239 SfxViewFrame* pFrm = SfxViewFrame::GetFirst( this );
1240 if( pFrm )
1241 pFrm->GetSlotState( nWh, NULL, &rSet );
1242 else
1243 rSet.DisableItem( nWh );
1245 break;
1247 case SID_GETUNDOSTRINGS:
1248 case SID_GETREDOSTRINGS:
1250 SfxUndoManager* pTmpUndoMgr = GetUndoManager();
1251 if( pTmpUndoMgr )
1253 UniString(SfxUndoManager:: *fnGetComment)( USHORT ) const;
1255 sal_uInt16 nCount;
1256 if( SID_GETUNDOSTRINGS == nWh )
1258 nCount = pTmpUndoMgr->GetUndoActionCount();
1259 fnGetComment = &SfxUndoManager::GetUndoActionComment;
1261 else
1263 nCount = pTmpUndoMgr->GetRedoActionCount();
1264 fnGetComment = &SfxUndoManager::GetRedoActionComment;
1266 if( nCount )
1268 String sList;
1269 for( sal_uInt16 n = 0; n < nCount; ++n )
1270 ( sList += (pTmpUndoMgr->*fnGetComment)( n ) )
1271 += '\n';
1273 SfxStringListItem aItem( nWh );
1274 aItem.SetString( sList );
1275 rSet.Put( aItem );
1278 else
1279 rSet.DisableItem( nWh );
1281 break;
1287 SfxUndoManager *SmDocShell::GetUndoManager()
1289 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::GetUndoManager" );
1291 if (!pEditEngine)
1292 GetEditEngine();
1293 return &pEditEngine->GetUndoManager();
1297 void SmDocShell::SaveSymbols()
1299 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::SaveSymbols" );
1301 SmModule *pp = SM_MOD();
1302 pp->GetSymbolManager().Save();
1306 void SmDocShell::Draw(OutputDevice *pDevice,
1307 const JobSetup &,
1308 USHORT /*nAspect*/)
1310 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::Draw" );
1312 pDevice->IntersectClipRegion(GetVisArea());
1313 Point atmppoint;
1314 Draw(*pDevice, atmppoint);
1317 SfxItemPool& SmDocShell::GetPool() const
1319 return SFX_APP()->GetPool();
1322 void SmDocShell::SetVisArea(const Rectangle & rVisArea)
1324 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::SetVisArea" );
1326 Rectangle aNewRect(rVisArea);
1328 aNewRect.SetPos(Point());
1330 if (! aNewRect.Right()) aNewRect.Right() = 2000;
1331 if (! aNewRect.Bottom()) aNewRect.Bottom() = 1000;
1333 BOOL bIsEnabled = IsEnableSetModified();
1334 if ( bIsEnabled )
1335 EnableSetModified( FALSE );
1337 //TODO/LATER: it's unclear how this interacts with the SFX code
1338 // If outplace editing, then dont resize the OutplaceWindow. But the
1339 // ObjectShell has to resize. Bug 56470
1340 BOOL bUnLockFrame;
1341 if( GetCreateMode() == SFX_CREATE_MODE_EMBEDDED && !IsInPlaceActive() && GetFrame() )
1343 GetFrame()->LockAdjustPosSizePixel();
1344 bUnLockFrame = TRUE;
1346 else
1347 bUnLockFrame = FALSE;
1349 SfxObjectShell::SetVisArea( aNewRect );
1351 if( bUnLockFrame )
1352 GetFrame()->UnlockAdjustPosSizePixel();
1354 if ( bIsEnabled )
1355 EnableSetModified( bIsEnabled );
1359 void SmDocShell::FillClass(SvGlobalName* pClassName,
1360 sal_uInt32* pFormat,
1361 String* /*pAppName*/,
1362 String* pFullTypeName,
1363 String* pShortTypeName,
1364 sal_Int32 nFileFormat,
1365 sal_Bool bTemplate /* = sal_False */) const
1367 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::FillClass" );
1369 if (nFileFormat == SOFFICE_FILEFORMAT_60 )
1371 *pClassName = SvGlobalName(SO3_SM_CLASSID_60);
1372 *pFormat = SOT_FORMATSTR_ID_STARMATH_60;
1373 *pFullTypeName = String(SmResId(STR_MATH_DOCUMENT_FULLTYPE_CURRENT));
1374 *pShortTypeName = String(SmResId(RID_DOCUMENTSTR));
1376 else if (nFileFormat == SOFFICE_FILEFORMAT_8 )
1378 *pClassName = SvGlobalName(SO3_SM_CLASSID_60);
1379 *pFormat = bTemplate ? SOT_FORMATSTR_ID_STARMATH_8_TEMPLATE : SOT_FORMATSTR_ID_STARMATH_8;
1380 *pFullTypeName = String(SmResId(STR_MATH_DOCUMENT_FULLTYPE_CURRENT));
1381 *pShortTypeName = String(SmResId(RID_DOCUMENTSTR));
1385 ULONG SmDocShell::GetMiscStatus() const
1387 return SfxObjectShell::GetMiscStatus() | SVOBJ_MISCSTATUS_NOTRESIZEABLE
1388 | SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE;
1391 void SmDocShell::SetModified(BOOL bModified)
1393 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::SetModified" );
1395 if( IsEnableSetModified() )
1397 SfxObjectShell::SetModified( bModified );
1398 Broadcast(SfxSimpleHint(SFX_HINT_DOCCHANGED));
1402 BOOL SmDocShell::WriteAsMathType3( SfxMedium& rMedium )
1404 RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::WriteAsMathType3" );
1406 MathType aEquation( aText, pTree );
1408 BOOL bRet = 0 != aEquation.ConvertFromStarMath( rMedium );
1409 return bRet;