diff options
Diffstat (limited to 'starmath')
72 files changed, 5731 insertions, 6224 deletions
diff --git a/starmath/inc/action.hxx b/starmath/inc/action.hxx index 6e2375331de9..c59765ee45ac 100644 --- a/starmath/inc/action.hxx +++ b/starmath/inc/action.hxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: action.hxx,v $ - * $Revision: 1.5 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -30,7 +27,7 @@ #ifndef ACTION_HXX #define ACTION_HXX -#include <svtools/undo.hxx> +#include <svl/undo.hxx> #include "format.hxx" class SmDocShell; diff --git a/starmath/inc/applicat.hxx b/starmath/inc/applicat.hxx index a1e91b4d68bf..9c756496ae95 100644 --- a/starmath/inc/applicat.hxx +++ b/starmath/inc/applicat.hxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: applicat.hxx,v $ - * $Revision: 1.6 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/starmath/inc/config.hxx b/starmath/inc/config.hxx index 6528c81b45ac..c52e429923c9 100644 --- a/starmath/inc/config.hxx +++ b/starmath/inc/config.hxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: config.hxx,v $ - * $Revision: 1.5 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -30,8 +27,8 @@ #ifndef CONFIG_HXX #define CONFIG_HXX -#include <svtools/brdcst.hxx> -#include <svtools/lstner.hxx> +#include <svl/brdcst.hxx> +#include <svl/lstner.hxx> #include "format.hxx" #include "cfgitem.hxx" diff --git a/starmath/inc/dialog.hxx b/starmath/inc/dialog.hxx index a2814082a9e5..b019a5b08ee1 100644 --- a/starmath/inc/dialog.hxx +++ b/starmath/inc/dialog.hxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: dialog.hxx,v $ - * $Revision: 1.21 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/starmath/inc/document.hxx b/starmath/inc/document.hxx index fac4f1b0faa4..e983a22094f0 100644 --- a/starmath/inc/document.hxx +++ b/starmath/inc/document.hxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: document.hxx,v $ - * $Revision: 1.35.26.1 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -35,14 +32,13 @@ #include <sot/storage.hxx> #include <sot/sotref.hxx> #include <sfx2/objsh.hxx> -#include <svtools/lstner.hxx> +#include <svl/lstner.hxx> #include <sfx2/docfac.hxx> #include <vcl/virdev.hxx> + #include "format.hxx" #include "parse.hxx" -#ifndef SMMOD_HXX #include "smmod.hxx" -#endif #include <vcl/jobset.hxx> @@ -84,6 +80,8 @@ class Printer; class SmDocShell; class EditEngine; +//////////////////////////////////////////////////////////// + class SmPrinterAccess { Printer* pPrinter; diff --git a/starmath/inc/edit.hxx b/starmath/inc/edit.hxx index d453fc6216e5..4abbcdb950d8 100644 --- a/starmath/inc/edit.hxx +++ b/starmath/inc/edit.hxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: edit.hxx,v $ - * $Revision: 1.15 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -33,7 +30,7 @@ #include <vcl/window.hxx> #include <vcl/timer.hxx> #include <svtools/transfer.hxx> -#include <svx/editdata.hxx> +#include <editeng/editdata.hxx> #include <svtools/colorcfg.hxx> //#ifndef _ACCESSIBILITY_HXX_ diff --git a/starmath/inc/format.hxx b/starmath/inc/format.hxx index 05375f8a73e0..f632131d834f 100644 --- a/starmath/inc/format.hxx +++ b/starmath/inc/format.hxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: format.hxx,v $ - * $Revision: 1.9 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -31,8 +28,8 @@ #define FORMAT_HXX -#include <svtools/smplhint.hxx> -#include <svtools/brdcst.hxx> +#include <svl/smplhint.hxx> +#include <svl/brdcst.hxx> #include "utility.hxx" #include <types.hxx> diff --git a/starmath/inc/makefile.mk b/starmath/inc/makefile.mk index efff07a65c7f..930e5281c6fb 100644 --- a/starmath/inc/makefile.mk +++ b/starmath/inc/makefile.mk @@ -2,14 +2,10 @@ # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # -# Copyright 2008 by Sun Microsystems, Inc. +# Copyright 2000, 2010 Oracle and/or its affiliates. # # OpenOffice.org - a multi-platform office productivity suite # -# $RCSfile: makefile.mk,v $ -# -# $Revision: 1.4 $ -# # This file is part of OpenOffice.org. # # OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/starmath/inc/node.hxx b/starmath/inc/node.hxx index 867c9508a074..f9fed9c9602a 100644 --- a/starmath/inc/node.hxx +++ b/starmath/inc/node.hxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: node.hxx,v $ - * $Revision: 1.19 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/starmath/inc/parse.hxx b/starmath/inc/parse.hxx index 5a7960d24435..b3ad5ef5bdc3 100644 --- a/starmath/inc/parse.hxx +++ b/starmath/inc/parse.hxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: parse.hxx,v $ - * $Revision: 1.10 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/starmath/inc/pch/precompiled_starmath.cxx b/starmath/inc/pch/precompiled_starmath.cxx index 623d05d436b8..e47f70d5909d 100644 --- a/starmath/inc/pch/precompiled_starmath.cxx +++ b/starmath/inc/pch/precompiled_starmath.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: precompiled_starmath.cxx,v $ - * $Revision: 1.3 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/starmath/inc/pch/precompiled_starmath.hxx b/starmath/inc/pch/precompiled_starmath.hxx index dd9cc263e855..51f5fa1fed8c 100644 --- a/starmath/inc/pch/precompiled_starmath.hxx +++ b/starmath/inc/pch/precompiled_starmath.hxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: precompiled_starmath.hxx,v $ - * $Revision: 1.3 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/starmath/inc/rect.hxx b/starmath/inc/rect.hxx index f4c891f85e95..f1af81c5c163 100644 --- a/starmath/inc/rect.hxx +++ b/starmath/inc/rect.hxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: rect.hxx,v $ - * $Revision: 1.7 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/starmath/inc/smdll.hxx b/starmath/inc/smdll.hxx index 8639ff03ed8a..79f51a82f912 100644 --- a/starmath/inc/smdll.hxx +++ b/starmath/inc/smdll.hxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: smdll.hxx,v $ - * $Revision: 1.4 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/starmath/inc/smmod.hxx b/starmath/inc/smmod.hxx index 4b493c0cbca7..bd8292e9a7b1 100644 --- a/starmath/inc/smmod.hxx +++ b/starmath/inc/smmod.hxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: smmod.hxx,v $ - * $Revision: 1.18 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -34,7 +31,7 @@ #ifndef _SV_RESARY_HXX #include <tools/resary.hxx> #endif -#include <svtools/lstner.hxx> +#include <svl/lstner.hxx> #include <svtools/colorcfg.hxx> #include <tools/shl.hxx> @@ -44,6 +41,8 @@ #include "starmath.hrc" #endif +#include <unotools/options.hxx> + class SvxErrorHandler; class SfxObjectFactory; class SmConfig; @@ -124,7 +123,7 @@ public: ///////////////////////////////////////////////////////////////// -class SmModule : public SfxModule, public SfxListener +class SmModule : public SfxModule, utl::ConfigurationListener { svtools::ColorConfig *pColorConfig; SmConfig *pConfig; @@ -145,8 +144,7 @@ public: SmModule(SfxObjectFactory* pObjFact); virtual ~SmModule(); - // SfxListener - virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); + virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 ); svtools::ColorConfig & GetColorConfig(); diff --git a/starmath/inc/starmath.hrc b/starmath/inc/starmath.hrc index 6d117bcc9524..2fbc7b4066d1 100644 --- a/starmath/inc/starmath.hrc +++ b/starmath/inc/starmath.hrc @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: starmath.hrc,v $ - * $Revision: 1.20 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -30,13 +27,9 @@ #ifndef _STARMATH_HRC #define _STARMATH_HRC -#ifndef _SVX_SVXIDS_HRC -#include <svtools/solar.hrc> -#endif -#ifndef _SFXSIDS_HRC //autogen +#include <svl/solar.hrc> #include <sfx2/sfxsids.hrc> -#endif - +#include <editeng/memberids.hrc> #define SID_NEXTERR (SID_SMA_START + 1) #define SID_PREVERR (SID_SMA_START + 2) @@ -103,6 +96,8 @@ #define RID_SYMBOLDIALOG (RID_APP_START + 8) #define RID_SYMDEFINEDIALOG (RID_APP_START + 9) #define RID_EXTRAOPTIONPAGE (RID_APP_START + 10) +#define RID_PRINTUIOPTIONS (RID_APP_START + 11) + #define RID_MATH_TOOLBOX (RID_APP_START + 50) // wegen #58705# entfernt //#define RID_DRAW_OBJECTBAR (RID_APP_START + 51) diff --git a/starmath/inc/symbol.hxx b/starmath/inc/symbol.hxx index d39376c30ed0..8c8df60c2c6e 100644 --- a/starmath/inc/symbol.hxx +++ b/starmath/inc/symbol.hxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: symbol.hxx,v $ - * $Revision: 1.17 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -37,8 +34,8 @@ #include <tools/list.hxx> #include <tools/debug.hxx> #include <tools/dynary.hxx> -#include <svtools/lstner.hxx> -#include <svtools/svarray.hxx> +#include <svl/lstner.hxx> +#include <svl/svarray.hxx> #include "utility.hxx" #include <smmod.hxx> diff --git a/starmath/inc/toolbox.hxx b/starmath/inc/toolbox.hxx index 81f2145773aa..1881adc0f845 100644 --- a/starmath/inc/toolbox.hxx +++ b/starmath/inc/toolbox.hxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: toolbox.hxx,v $ - * $Revision: 1.11 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/starmath/inc/types.hxx b/starmath/inc/types.hxx index 3cf63b076391..2ad899f37cc7 100644 --- a/starmath/inc/types.hxx +++ b/starmath/inc/types.hxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: types.hxx,v $ - * $Revision: 1.9 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -31,9 +28,9 @@ #define TYPES_HXX #include <sal/types.h> +#include <tools/debug.hxx> -#define FONTNAME_MATH "StarSymbol" -#define FONTNAME_MATH2 "OpenSymbol" +#define FONTNAME_MATH "OpenSymbol" ///////////////////////////////////////////////////////////////// @@ -54,19 +51,8 @@ inline sal_Bool IsInPrivateUseArea( sal_Unicode cChar ) { return 0xE000 <= cChar inline sal_Bool IsGreekChar( sal_Unicode cChar ) { return 0x0370 <= cChar && cChar <= 0x03FF; } sal_Unicode ConvertMathPrivateUseAreaToUnicode( sal_Unicode cChar ); -#ifdef TL_NOT_YET_USED -sal_Unicode ConvertUnicodeToMathPrivateUseArea( sal_Unicode cChar ); - -sal_Unicode ConvertMathToMathType( sal_Unicode cChar ); -sal_Unicode ConvertMathTypeToMath( sal_Unicode cChar ); -#endif //TL_NOT_YET_USED sal_Unicode ConvertMathToMathML( sal_Unicode cChar ); -#ifdef TL_NOT_YET_USED -sal_Unicode ConvertMathMLToMath( sal_Unicode cChar ); - -sal_Unicode GetTokenChar( sal_Unicode cChar, sal_Bool bConvertForExport ); -#endif //TL_NOT_YET_USED ///////////////////////////////////////////////////////////////// // enum definitions for characters from the 'StarSymbol' font @@ -84,14 +70,14 @@ enum MathSymbol MS_DRARROW = (sal_Unicode) 0x21D2, MS_DLARROW = (sal_Unicode) 0x21D0, MS_DLRARROW = (sal_Unicode) 0x21D4, - MS_UNDERBRACE = (sal_Unicode) 0xE081, - MS_OVERBRACE = (sal_Unicode) 0xE082, - MS_CIRC = (sal_Unicode) 0x00B0, + MS_OVERBRACE = (sal_Unicode) 0x23DE, + MS_UNDERBRACE = (sal_Unicode) 0x23DF, + MS_CIRC = (sal_Unicode) 0x2218, MS_ASSIGN = (sal_Unicode) 0x003D, MS_ERROR = (sal_Unicode) 0x00BF, MS_NEQ = (sal_Unicode) 0x2260, - MS_PLUS = (sal_Unicode) 0xE083, + MS_PLUS = (sal_Unicode) 0x002B, MS_MINUS = (sal_Unicode) 0x2212, MS_MULTIPLY = (sal_Unicode) 0x2217, MS_TIMES = (sal_Unicode) 0x00D7, @@ -107,23 +93,23 @@ enum MathSymbol MS_UNION = (sal_Unicode) 0x222A, MS_INTERSECT = (sal_Unicode) 0x2229, - MS_LT = (sal_Unicode) 0xE084, - MS_GT = (sal_Unicode) 0xE085, + MS_LT = (sal_Unicode) 0x003C, + MS_GT = (sal_Unicode) 0x003E, MS_LE = (sal_Unicode) 0x2264, MS_GE = (sal_Unicode) 0x2265, - MS_LESLANT = (sal_Unicode) 0xE086, - MS_GESLANT = (sal_Unicode) 0xE087, + MS_LESLANT = (sal_Unicode) 0x2A7D, + MS_GESLANT = (sal_Unicode) 0x2A7E, MS_LL = (sal_Unicode) 0x226A, MS_GG = (sal_Unicode) 0x226B, - MS_SIM = (sal_Unicode) 0x007E, + MS_SIM = (sal_Unicode) 0x223C, MS_SIMEQ = (sal_Unicode) 0x2243, MS_APPROX = (sal_Unicode) 0x2248, MS_DEF = (sal_Unicode) 0x225D, MS_EQUIV = (sal_Unicode) 0x2261, MS_PROP = (sal_Unicode) 0x221D, MS_PARTIAL = (sal_Unicode) 0x2202, - MS_SUBSET = (sal_Unicode) 0x2282, + MS_SUBSET = (sal_Unicode) 0x2282, MS_SUPSET = (sal_Unicode) 0x2283, MS_SUBSETEQ = (sal_Unicode) 0x2286, MS_SUPSETEQ = (sal_Unicode) 0x2287, @@ -143,70 +129,69 @@ enum MathSymbol MS_LINE = (sal_Unicode) 0x2223, MS_DLINE = (sal_Unicode) 0x2225, MS_ORTHO = (sal_Unicode) 0x22A5, - MS_DOTSLOW = (sal_Unicode) 0xE08B, + MS_DOTSLOW = (sal_Unicode) 0x2026, MS_DOTSAXIS = (sal_Unicode) 0x22EF, MS_DOTSVERT = (sal_Unicode) 0x22EE, MS_DOTSUP = (sal_Unicode) 0x22F0, MS_DOTSDOWN = (sal_Unicode) 0x22F1, MS_TRANSR = (sal_Unicode) 0x22B6, MS_TRANSL = (sal_Unicode) 0x22B7, - MS_RIGHTARROW = (sal_Unicode) 0xE08C, MS_BACKSLASH = (sal_Unicode) 0x2216, MS_NEG = (sal_Unicode) 0x00AC, + MS_FORALL = (sal_Unicode) 0x2200, + MS_NABLA = (sal_Unicode) 0x2207, + MS_PROD = (sal_Unicode) 0x220F, + MS_COPROD = (sal_Unicode) 0x2210, + MS_SUM = (sal_Unicode) 0x2211, + MS_SQRT = (sal_Unicode) 0x221A, MS_INT = (sal_Unicode) 0x222B, MS_IINT = (sal_Unicode) 0x222C, MS_IIINT = (sal_Unicode) 0x222D, MS_LINT = (sal_Unicode) 0x222E, MS_LLINT = (sal_Unicode) 0x222F, MS_LLLINT = (sal_Unicode) 0x2230, - MS_SQRT = (sal_Unicode) 0xE08D, - MS_COPROD = (sal_Unicode) 0x2210, - MS_PROD = (sal_Unicode) 0x220F, - MS_SUM = (sal_Unicode) 0x2211, - MS_NABLA = (sal_Unicode) 0x2207, - MS_FORALL = (sal_Unicode) 0x2200, - MS_HAT = (sal_Unicode) 0xE091, - MS_CHECK = (sal_Unicode) 0xE092, - MS_BREVE = (sal_Unicode) 0xE093, - MS_ACUTE = (sal_Unicode) 0xE094, - MS_GRAVE = (sal_Unicode) 0xE095, - MS_TILDE = (sal_Unicode) 0xE096, - MS_BAR = (sal_Unicode) 0xE097, - MS_VEC = (sal_Unicode) 0xE098, + MS_GRAVE = (sal_Unicode) 0x0300, + MS_ACUTE = (sal_Unicode) 0x0301, + MS_HAT = (sal_Unicode) 0x0302, + MS_TILDE = (sal_Unicode) 0x0303, + MS_BAR = (sal_Unicode) 0x0304, + MS_BREVE = (sal_Unicode) 0x0306, + MS_CIRCLE = (sal_Unicode) 0x030A, + MS_CHECK = (sal_Unicode) 0x030C, + MS_VEC = (sal_Unicode) 0x20D7, MS_DOT = (sal_Unicode) 0x02D9, MS_DDOT = (sal_Unicode) 0x00A8, - MS_DDDOT = (sal_Unicode) 0xE09B, - MS_CIRCLE = (sal_Unicode) 0x02DA, + MS_DDDOT = (sal_Unicode) 0x20DB, MS_AND = (sal_Unicode) 0x2227, MS_OR = (sal_Unicode) 0x2228, MS_NI = (sal_Unicode) 0x220B, MS_EMPTYSET = (sal_Unicode) 0x2205, - MS_LBRACE = (sal_Unicode) 0x007B, - MS_RBRACE = (sal_Unicode) 0x007D, - MS_LPARENT = (sal_Unicode) 0xE09E, - MS_RPARENT = (sal_Unicode) 0xE09F, - MS_LANGLE = (sal_Unicode) 0x2329, - MS_RANGLE = (sal_Unicode) 0x232A, + MS_LPARENT = (sal_Unicode) 0x0028, + MS_RPARENT = (sal_Unicode) 0x0029, MS_LBRACKET = (sal_Unicode) 0x005B, MS_RBRACKET = (sal_Unicode) 0x005D, - - MS_LDBRACKET = (sal_Unicode) 0x301A, - MS_RDBRACKET = (sal_Unicode) 0x301B, - MS_PLACE = (sal_Unicode) 0xE0AA, - + MS_LBRACE = (sal_Unicode) 0x007B, + MS_RBRACE = (sal_Unicode) 0x007D, MS_LCEIL = (sal_Unicode) 0x2308, - MS_LFLOOR = (sal_Unicode) 0x230A, MS_RCEIL = (sal_Unicode) 0x2309, + MS_LFLOOR = (sal_Unicode) 0x230A, MS_RFLOOR = (sal_Unicode) 0x230B, + MS_LANGLE = (sal_Unicode) 0x2329, + MS_RANGLE = (sal_Unicode) 0x232A, + MS_LDBRACKET = (sal_Unicode) 0x27E6, + MS_RDBRACKET = (sal_Unicode) 0x27E7, + + MS_PLACE = (sal_Unicode) 0x2751, - MS_HBAR = (sal_Unicode) 0x210F, MS_LAMBDABAR = (sal_Unicode) 0x019B, - MS_LEFTARROW = (sal_Unicode) 0xE0DB, - MS_UPARROW = (sal_Unicode) 0xE0DC, - MS_DOWNARROW = (sal_Unicode) 0xE0DD, + MS_HBAR = (sal_Unicode) 0x210F, + MS_LEFTARROW = (sal_Unicode) 0x2190, + MS_UPARROW = (sal_Unicode) 0x2191, + MS_RIGHTARROW = (sal_Unicode) 0x2192, + MS_DOWNARROW = (sal_Unicode) 0x2193, MS_SETN = (sal_Unicode) 0x2115, MS_SETZ = (sal_Unicode) 0x2124, MS_SETQ = (sal_Unicode) 0x211A, diff --git a/starmath/inc/unomodel.hxx b/starmath/inc/unomodel.hxx index 50cdc372d593..8ee5795c38b4 100644 --- a/starmath/inc/unomodel.hxx +++ b/starmath/inc/unomodel.hxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: unomodel.hxx,v $ - * $Revision: 1.13 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -35,11 +32,30 @@ #include <com/sun/star/beans/XPropertyState.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/view/XRenderable.hpp> + #include <sfx2/sfxbasemodel.hxx> #include <comphelper/propertysethelper.hxx> +#include <vcl/print.hxx> class SmFormat; +//////////////////////////////////////////////////////////// + +#define PRTUIOPT_TITLE_ROW "TitleRow" +#define PRTUIOPT_FORMULA_TEXT "FormulaText" +#define PRTUIOPT_BORDER "Border" +#define PRTUIOPT_PRINT_FORMAT "PrintFormat" +#define PRTUIOPT_PRINT_SCALE "PrintScale" + +class SmPrintUIOptions : public vcl::PrinterOptionsHelper +{ +public: + SmPrintUIOptions(); +}; + + +//////////////////////////////////////////////////////////// + #define A2OU(pText) rtl::OUString::createFromAscii(pText) //----------------------------------------------------------------------------- @@ -48,6 +64,7 @@ class SmModel : public SfxBaseModel, public com::sun::star::lang::XServiceInfo, public com::sun::star::view::XRenderable { + SmPrintUIOptions* m_pPrintUIOptions; protected: virtual void _setPropertyValues( const comphelper::PropertyMapEntry** ppEntries, const ::com::sun::star::uno::Any* pValues ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException ); @@ -86,4 +103,7 @@ public: static ::rtl::OUString getImplementationName_Static(); }; +//////////////////////////////////////////////////////////// + #endif + diff --git a/starmath/inc/utility.hxx b/starmath/inc/utility.hxx index cbb8f00cc712..e7db51152e25 100644 --- a/starmath/inc/utility.hxx +++ b/starmath/inc/utility.hxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: utility.hxx,v $ - * $Revision: 1.11 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/starmath/inc/view.hxx b/starmath/inc/view.hxx index 8c89d9517898..d414d1e72309 100644 --- a/starmath/inc/view.hxx +++ b/starmath/inc/view.hxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: view.hxx,v $ - * $Revision: 1.24 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -47,6 +44,7 @@ class DataChangedEvent; class SmClipboardChangeListener; class SmDocShell; class SmViewShell; +class SmPrintUIOptions; /**************************************************************************/ @@ -292,8 +290,8 @@ public: virtual void Execute( SfxRequest& rReq ); virtual void GetState(SfxItemSet &); - void Impl_Print( OutputDevice &rOutDev, const SmPrintSize ePrintSize, - Rectangle aOutRect, Point aZeroPoint ); + void Impl_Print( OutputDevice &rOutDev, const SmPrintUIOptions &rPrintUIOptions, + Rectangle aOutRect, Point aZeroPoint ); }; #endif diff --git a/starmath/qa/unoapi/makefile.mk b/starmath/qa/unoapi/makefile.mk index c37570b3af3d..93169ee51708 100644 --- a/starmath/qa/unoapi/makefile.mk +++ b/starmath/qa/unoapi/makefile.mk @@ -2,14 +2,10 @@ # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # -# Copyright 2008 by Sun Microsystems, Inc. +# Copyright 2000, 2010 Oracle and/or its affiliates. # # OpenOffice.org - a multi-platform office productivity suite # -# $RCSfile: makefile.mk,v $ -# -# $Revision: 1.6 $ -# # This file is part of OpenOffice.org. # # OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/starmath/sdi/makefile.mk b/starmath/sdi/makefile.mk index 768280af9747..a2d965bc2275 100644 --- a/starmath/sdi/makefile.mk +++ b/starmath/sdi/makefile.mk @@ -2,14 +2,10 @@ # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # -# Copyright 2008 by Sun Microsystems, Inc. +# Copyright 2000, 2010 Oracle and/or its affiliates. # # OpenOffice.org - a multi-platform office productivity suite # -# $RCSfile: makefile.mk,v $ -# -# $Revision: 1.8 $ -# # This file is part of OpenOffice.org. # # OpenOffice.org is free software: you can redistribute it and/or modify @@ -46,8 +42,12 @@ SVSDIINC=$(PRJ)$/inc SDI1NAME=$(TARGET) SVSDI1DEPEND= \ - $(SOLARINCDIR)$/svxslots.ilb \ - smath.sdi \ + $(SOLARINCXDIR)$/sfx2/sfx.sdi \ + $(SOLARINCXDIR)$/sfx2/sfxitems.sdi \ + $(SOLARINCXDIR)$/svx/svx.sdi \ + $(SOLARINCXDIR)$/svx/svxitems.sdi \ + $(SOLARINCXDIR)$/svx/xoitems.sdi \ + smath.sdi \ smslots.sdi \ $(SVSDIINC)$/starmath.hrc diff --git a/starmath/sdi/smath.sdi b/starmath/sdi/smath.sdi index 04c061359ada..f1f812e6c40b 100644 --- a/starmath/sdi/smath.sdi +++ b/starmath/sdi/smath.sdi @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: smath.sdi,v $ - * $Revision: 1.11 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/starmath/sdi/svxitems.sdi b/starmath/sdi/smitems.sdi index ddbf0f2fc185..019d2c5f5312 100644 --- a/starmath/sdi/svxitems.sdi +++ b/starmath/sdi/smitems.sdi @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: svxitems.sdi,v $ - * $Revision: 1.4 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/starmath/sdi/smslots.sdi b/starmath/sdi/smslots.sdi index 40b9da78d7ff..9e27c7149502 100644 --- a/starmath/sdi/smslots.sdi +++ b/starmath/sdi/smslots.sdi @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: smslots.sdi,v $ - * $Revision: 1.10 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -28,8 +25,6 @@ * ************************************************************************/ -import "svxslots.ilb" - module "312C4240-35E7-101C-B12A-04021C007002" "58216740-35E7-101C-B12A-04021C007002" @@ -37,11 +32,16 @@ StarMath [ HelpText ( "StarMath Application" ) SlotIdFile ( "starmath.hrc" ) + SlotIdFile ( "editeng/editids.hrc" ) SlotIdFile ( "sfx2/sfxsids.hrc" ) SlotIdFile ( "svx/svxids.hrc" ) - TypeLibFile ( "smslots.tlb" ) ] { + include "sfx2/sfxitems.sdi" + include "sfx2/sfx.sdi" + include "svx/svxitems.sdi" + include "svx/xoitems.sdi" + include "svx/svx.sdi" include "smath.sdi" interface StarMath [ @@ -59,7 +59,7 @@ shell SmModule import StarMath[Automation]; } -interface FormulaDocument : OfficeDocument +interface FormulaDocument [ uuid ( "815CBB20-2FC3-11CF-89CA-008029E4B0B1" ) ] @@ -149,13 +149,13 @@ interface FormulaDocument : OfficeDocument ] } -shell SmDocShell : SfxObjectShell +shell SmDocShell { import FormulaDocument[Automation]; } -interface FormulaView : View +interface FormulaView [ uuid ( "CE1A6C00-2FC3-11CF-89CA-008029E4B0B1" ) ] @@ -323,7 +323,7 @@ interface FormulaView : View ] } -shell SmViewShell : SfxViewShell +shell SmViewShell { import FormulaView[Automation]; } diff --git a/starmath/source/accessibility.cxx b/starmath/source/accessibility.cxx index f258d7f31176..20baff5ea42e 100644 --- a/starmath/source/accessibility.cxx +++ b/starmath/source/accessibility.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: accessibility.cxx,v $ - * $Revision: 1.38 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -51,14 +48,14 @@ #include <vcl/unohelp2.hxx> #include <tools/gen.hxx> #include <vos/mutex.hxx> -#include <svtools/itemset.hxx> - -#include <svx/editobj.hxx> -#include <svx/editdata.hxx> -#include <svx/editview.hxx> -#include <svx/eeitem.hxx> -#include <svx/outliner.hxx> -#include <svx/unoedhlp.hxx> +#include <svl/itemset.hxx> + +#include <editeng/editobj.hxx> +#include <editeng/editdata.hxx> +#include <editeng/editview.hxx> +#include <editeng/eeitem.hxx> +#include <editeng/outliner.hxx> +#include <editeng/unoedhlp.hxx> #include "accessibility.hxx" diff --git a/starmath/source/accessibility.hxx b/starmath/source/accessibility.hxx index 7199583dd4ff..32c8615fc1bb 100644 --- a/starmath/source/accessibility.hxx +++ b/starmath/source/accessibility.hxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: accessibility.hxx,v $ - * $Revision: 1.24 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -52,10 +49,10 @@ #include <cppuhelper/interfacecontainer.h> #include <cppuhelper/implbase5.hxx> #include <cppuhelper/implbase6.hxx> -#include <svtools/brdcst.hxx> +#include <svl/brdcst.hxx> -#include <svx/editeng.hxx> -#include <svx/unoedsrc.hxx> // SvxEditSource, SvxTextForwarder, SvxViewForwarder, SvxEditViewForwarder +#include <editeng/editeng.hxx> +#include <editeng/unoedsrc.hxx> // SvxEditSource, SvxTextForwarder, SvxViewForwarder, SvxEditViewForwarder #include <svx/AccessibleTextHelper.hxx> #include <edit.hxx> diff --git a/starmath/source/action.cxx b/starmath/source/action.cxx index b2833abdde0d..cef82f23b5f3 100644 --- a/starmath/source/action.cxx +++ b/starmath/source/action.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: action.cxx,v $ - * $Revision: 1.6 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/starmath/source/cfgitem.cxx b/starmath/source/cfgitem.cxx index 175c41c173eb..da507871ed61 100644 --- a/starmath/source/cfgitem.cxx +++ b/starmath/source/cfgitem.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: cfgitem.cxx,v $ - * $Revision: 1.20 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -1279,6 +1276,8 @@ void SmMathConfig::SetShowFormulaCursor( BOOL bVal ) SetOtherIfNotEqual( pOther->bFormulaCursor, bVal ); } +void SmMathConfig::Notify( const com::sun::star::uno::Sequence< rtl::OUString >& ) +{} ///////////////////////////////////////////////////////////////// diff --git a/starmath/source/cfgitem.hxx b/starmath/source/cfgitem.hxx index 4c028039ea5e..514573f6e7ac 100644 --- a/starmath/source/cfgitem.hxx +++ b/starmath/source/cfgitem.hxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: cfgitem.hxx,v $ - * $Revision: 1.14 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -44,7 +41,7 @@ #include <tools/solar.h> #include <rtl/ustring.hxx> #include <unotools/configitem.hxx> -#include <svtools/svarray.hxx> +#include <svl/svarray.hxx> #include <vcl/timer.hxx> #include <symbol.hxx> @@ -174,7 +171,7 @@ public: virtual ~SmMathConfig(); // utl::ConfigItem - //virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString > &rPropertyNames ); + virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString > &rPropertyNames ); virtual void Commit(); // make some protected functions of utl::ConfigItem public diff --git a/starmath/source/commands.src b/starmath/source/commands.src index a154139160ab..75c00cb819a6 100644 --- a/starmath/source/commands.src +++ b/starmath/source/commands.src @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: commands.src,v $ - * $Revision: 1.31 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/starmath/source/config.cxx b/starmath/source/config.cxx index b778571a5c0f..16b3b97afd96 100644 --- a/starmath/source/config.cxx +++ b/starmath/source/config.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: config.cxx,v $ - * $Revision: 1.12 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -32,15 +29,15 @@ #include "precompiled_starmath.hxx" -#include <svtools/itemset.hxx> -#include <svtools/hint.hxx> -#include <svtools/smplhint.hxx> -#include <svtools/pathoptions.hxx> +#include <svl/itemset.hxx> +#include <svl/hint.hxx> +#include <svl/smplhint.hxx> +#include <unotools/pathoptions.hxx> #include <sfx2/sfxsids.hrc> -#include <svtools/eitem.hxx> -#include <svtools/itempool.hxx> -#include <svtools/stritem.hxx> -#include <svtools/intitem.hxx> +#include <svl/eitem.hxx> +#include <svl/itempool.hxx> +#include <svl/stritem.hxx> +#include <svl/intitem.hxx> #include <tools/stream.hxx> diff --git a/starmath/source/detreg.cxx b/starmath/source/detreg.cxx index ee9edbd5f735..c79813f994a7 100644 --- a/starmath/source/detreg.cxx +++ b/starmath/source/detreg.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: detreg.cxx,v $ - * $Revision: 1.6 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/starmath/source/dialog.cxx b/starmath/source/dialog.cxx index 0f7e233cde87..257fdb959484 100644 --- a/starmath/source/dialog.cxx +++ b/starmath/source/dialog.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: dialog.cxx,v $ - * $Revision: 1.44 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -34,9 +31,9 @@ #define SMDLL 1 #include "tools/rcid.h" -#include <svtools/eitem.hxx> -#include <svtools/intitem.hxx> -#include <svtools/stritem.hxx> +#include <svl/eitem.hxx> +#include <svl/intitem.hxx> +#include <svl/stritem.hxx> #include <sfx2/app.hxx> #include <vcl/msgbox.hxx> #include <svtools/ctrltool.hxx> diff --git a/starmath/source/dialog.hrc b/starmath/source/dialog.hrc index 35c7d77391f1..29d87ba1d287 100644 --- a/starmath/source/dialog.hrc +++ b/starmath/source/dialog.hrc @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: dialog.hrc,v $ - * $Revision: 1.6 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx index 03beb26f7bb2..aac3f65c14e6 100644 --- a/starmath/source/document.cxx +++ b/starmath/source/document.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: document.cxx,v $ - * $Revision: 1.94.26.1 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -55,33 +52,33 @@ #include <sot/exchange.hxx> #include <sot/formats.hxx> #include <sot/storage.hxx> -#include <svtools/eitem.hxx> -#include <svtools/fstathelper.hxx> -#include <svtools/intitem.hxx> -#include <svtools/itempool.hxx> -#include <svtools/lingucfg.hxx> -#include <svtools/linguprops.hxx> -#include <svtools/pathoptions.hxx> -#include <svtools/ptitem.hxx> +#include <svl/eitem.hxx> +#include <svl/fstathelper.hxx> +#include <svl/intitem.hxx> +#include <svl/itempool.hxx> +#include <unotools/lingucfg.hxx> +#include <unotools/linguprops.hxx> +#include <unotools/pathoptions.hxx> +#include <svl/ptitem.hxx> #include <svtools/sfxecode.hxx> -#include <svtools/slstitm.hxx> -#include <svtools/smplhint.hxx> -#include <svtools/stritem.hxx> +#include <svl/slstitm.hxx> +#include <svl/smplhint.hxx> +#include <svl/stritem.hxx> #include <svtools/transfer.hxx> -#include <svtools/undo.hxx> -#include <svtools/urihelper.hxx> -#include <svtools/whiter.hxx> -#include <svx/editeng.hxx> -#include <svx/editstat.hxx> -#include <svx/eeitem.hxx> -#include <svx/fhgtitem.hxx> -#include <svx/fontitem.hxx> -#include <svx/unolingu.hxx> +#include <svl/undo.hxx> +#include <svl/urihelper.hxx> +#include <svl/whiter.hxx> +#include <editeng/editeng.hxx> +#include <editeng/editstat.hxx> +#include <editeng/eeitem.hxx> +#include <editeng/fhgtitem.hxx> +#include <editeng/fontitem.hxx> +#include <editeng/unolingu.hxx> #include <ucbhelper/content.hxx> #include <vcl/mapmod.hxx> #include <vcl/mapunit.hxx> #include <vcl/msgbox.hxx> - +#include <sfx2/sfx.hrc> #include <document.hxx> #include <action.hxx> #include <config.hxx> @@ -97,8 +94,8 @@ #include "mathtype.hxx" #include "mathmlimport.hxx" #include "mathmlexport.hxx" - - +#include <sfx2/sfxsids.hrc> +#include <svx/svxids.hrc> using namespace ::com::sun::star; using namespace ::com::sun::star::accessibility; @@ -111,17 +108,12 @@ using namespace ::com::sun::star::uno; static const char __FAR_DATA pStarMathDoc[] = "StarMathDocument"; - -/**************************************************************************/ -/* -** -** CLASS IMPLEMENTATION -** -**/ - #define SmDocShell #include "smslots.hxx" +//////////////////////////////////////////////////////////// + + TYPEINIT1( SmDocShell, SfxObjectShell ); SFX_IMPL_INTERFACE(SmDocShell, SfxObjectShell, SmResId(0)) diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx index 8435b7b5f35a..94e30ce82501 100644 --- a/starmath/source/edit.cxx +++ b/starmath/source/edit.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: edit.cxx,v $ - * $Revision: 1.40 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -47,19 +44,19 @@ #include <vcl/menu.hxx> -#include <svx/editview.hxx> -#include <svx/editeng.hxx> -#include <svx/editstat.hxx> -#include <svx/eeitem.hxx> +#include <editeng/editview.hxx> +#include <editeng/editeng.hxx> +#include <editeng/editstat.hxx> +#include <editeng/eeitem.hxx> #include <sfx2/dispatch.hxx> -#include <svtools/intitem.hxx> -#include <svtools/itempool.hxx> -#include <svtools/stritem.hxx> -#include <svx/fhgtitem.hxx> -#include <svx/wghtitem.hxx> -#include <svx/lrspitem.hxx> -#include <svtools/itemset.hxx> -#include <svx/fontitem.hxx> +#include <svl/intitem.hxx> +#include <svl/itempool.hxx> +#include <svl/stritem.hxx> +#include <editeng/fhgtitem.hxx> +#include <editeng/wghtitem.hxx> +#include <editeng/lrspitem.hxx> +#include <svl/itemset.hxx> +#include <editeng/fontitem.hxx> #include <sfx2/viewfrm.hxx> #include "edit.hxx" diff --git a/starmath/source/eqnolefilehdr.cxx b/starmath/source/eqnolefilehdr.cxx index 784ec1fadb72..ed898bb982f1 100644 --- a/starmath/source/eqnolefilehdr.cxx +++ b/starmath/source/eqnolefilehdr.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: eqnolefilehdr.cxx,v $ - * $Revision: 1.5 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/starmath/source/eqnolefilehdr.hxx b/starmath/source/eqnolefilehdr.hxx index c1d0a0e39402..330f5767384c 100644 --- a/starmath/source/eqnolefilehdr.hxx +++ b/starmath/source/eqnolefilehdr.hxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: eqnolefilehdr.hxx,v $ - * $Revision: 1.4 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/starmath/source/format.cxx b/starmath/source/format.cxx index 9ecfd1720b1e..18aaed4c841c 100644 --- a/starmath/source/format.cxx +++ b/starmath/source/format.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: format.cxx,v $ - * $Revision: 1.14 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -34,7 +31,7 @@ #include <tools/stream.hxx> #include <vcl/svapp.hxx> -#include <svx/scripttypeitem.hxx> +#include <editeng/scripttypeitem.hxx> #include "format.hxx" ///////////////////////////////////////////////////////////////// @@ -49,7 +46,7 @@ static const USHORT aLatinDefFnts[FNT_END] = DEFAULTFONT_SERIF, // FNT_SERIF DEFAULTFONT_SANS, // FNT_SANS DEFAULTFONT_FIXED // FNT_FIXED - //StarSymbol, // FNT_MATH + //OpenSymbol, // FNT_MATH }; // CJK default-fonts @@ -65,7 +62,7 @@ static const USHORT aCJKDefFnts[FNT_END] = DEFAULTFONT_CJK_TEXT, // FNT_SERIF DEFAULTFONT_CJK_DISPLAY, // FNT_SANS DEFAULTFONT_CJK_TEXT // FNT_FIXED - //StarSymbol, // FNT_MATH + //OpenSymbol, // FNT_MATH }; // CTL default-fonts @@ -78,7 +75,7 @@ static const USHORT aCTLDefFnts[FNT_END] = DEFAULTFONT_CTL_TEXT, // FNT_SERIF DEFAULTFONT_CTL_TEXT, // FNT_SANS DEFAULTFONT_CTL_TEXT // FNT_FIXED - //StarSymbol, // FNT_MATH + //OpenSymbol, // FNT_MATH }; diff --git a/starmath/source/makefile.mk b/starmath/source/makefile.mk index 53f6569dcf9c..c3091423c1b8 100644 --- a/starmath/source/makefile.mk +++ b/starmath/source/makefile.mk @@ -2,14 +2,10 @@ # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # -# Copyright 2008 by Sun Microsystems, Inc. +# Copyright 2000, 2010 Oracle and/or its affiliates. # # OpenOffice.org - a multi-platform office productivity suite # -# $RCSfile: makefile.mk,v $ -# -# $Revision: 1.35 $ -# # This file is part of OpenOffice.org. # # OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/starmath/source/math_pch.cxx b/starmath/source/math_pch.cxx index 5ea88307fb2d..bcb768fe600b 100644 --- a/starmath/source/math_pch.cxx +++ b/starmath/source/math_pch.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: math_pch.cxx,v $ - * $Revision: 1.17 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -48,11 +45,11 @@ #include <tools/rtti.hxx> #include <tools/ref.hxx> #include <tools/link.hxx> -#include <svtools/brdcst.hxx> -#include <svtools/svarray.hxx> +#include <svl/brdcst.hxx> +#include <svl/svarray.hxx> #include <tools/debug.hxx> -#include <svtools/hint.hxx> -#include <svtools/smplhint.hxx> +#include <svl/hint.hxx> +#include <svl/smplhint.hxx> #include <sot/sotref.hxx> #include <tools/globname.hxx> #include <sot/factory.hxx> @@ -130,9 +127,9 @@ #include <smdll.hxx> #include <sfx2/sfxsids.hrc> #include <chaos/cntids.hrc> -#include <svtools/cntwids.hrc> -#include <svtools/solar.hrc> -#include <svtools/lstner.hxx> +#include <svl/cntwids.hrc> +#include <svl/solar.hrc> +#include <svl/lstner.hxx> #include <starmath.hrc> #include <basic/sbx.hxx> #include <basic/sbxform.hxx> @@ -143,7 +140,7 @@ #include <basic/sbxmeth.hxx> #include <tools/unqid.hxx> #include <tools/unqidx.hxx> -#include <svtools/poolitem.hxx> +#include <svl/poolitem.hxx> #include <svtools/args.hxx> #include <smmod.hxx> #include <vos/thread.hxx> @@ -156,7 +153,7 @@ #include <vcl/timer.hxx> #include <sfx2/app.hxx> #include <sfx2/sfx.hrc> -#include <svtools/memberid.hrc> +#include <svl/memberid.hrc> #include <vcl/syswin.hxx> #include <vcl/virdev.hxx> #include <tools/datetime.hxx> @@ -736,7 +733,7 @@ #endif #include <usr/refl.hxx> #include <sfx2/msg.hxx> -#include <svtools/itemset.hxx> +#include <svl/itemset.hxx> #include <sfx2/basedlgs.hxx> #include <vcl/floatwin.hxx> #include <vcl/dialog.hxx> @@ -745,10 +742,10 @@ #include <sfx2/frame.hxx> #include <sfx2/objface.hxx> #include <vcl/event.hxx> -#include <svtools/eitem.hxx> -#include <svtools/intitem.hxx> +#include <svl/eitem.hxx> +#include <svl/intitem.hxx> #include <symbol.hxx> -#include <svtools/itempool.hxx> +#include <svl/itempool.hxx> #include <vcl/image.hxx> #include <vcl/metric.hxx> #include <sfx2/inimgr.hxx> @@ -756,14 +753,14 @@ #include <tools/pstm.hxx> #include <tools/table.hxx> #include <sfx2/docfac.hxx> -#include <svtools/ownlist.hxx> +#include <svl/ownlist.hxx> #include <sfx2/objsh.hxx> -#include <svtools/stritem.hxx> +#include <svl/stritem.hxx> #include <vcl/mapmod.hxx> #include <sfx2/ipfrm.hxx> #include <vcl/dialog.hxx> #include <sfx2/dispatch.hxx> -#include <svtools/svstdarr.hxx> +#include <svl/svstdarr.hxx> #include <sfx2/bindings.hxx> #include <dialog.hxx> #include <vcl/button.hxx> @@ -817,14 +814,14 @@ #include <sfx2/ctrlitem.hxx> #include <sfx2/viewfac.hxx> #include <edit.hxx> -#include <svx/editdata.hxx> +#include <editeng/editdata.hxx> #include <toolbox.hxx> #include <vcl/toolbox.hxx> #include <vcl/dockwin.hxx> #include <smslots.hxx> -#include <svtools/undo.hxx> +#include <svl/undo.hxx> #include <sfx2/request.hxx> -#include <svtools/whiter.hxx> +#include <svl/whiter.hxx> #include <vcl/prntypes.hxx> #include <vcl/jobset.hxx> #include <vcl/gdimtf.hxx> diff --git a/starmath/source/mathmlexport.cxx b/starmath/source/mathmlexport.cxx index 9ddabab9c325..36eb9d3884b5 100644 --- a/starmath/source/mathmlexport.cxx +++ b/starmath/source/mathmlexport.cxx @@ -1,1568 +1,1565 @@ -/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: x $
- * $Revision: 1.00 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_starmath.hxx"
-
-/*
- Warning: The SvXMLElementExport helper class creates the beginning and
- closing tags of xml elements in its constructor and destructor, so theres
- hidden stuff going on, on occasion the ordering of these classes declarations
- may be significant
-*/
-
-
-#include <com/sun/star/xml/sax/XErrorHandler.hpp>
-#include <com/sun/star/xml/sax/XEntityResolver.hpp>
-#include <com/sun/star/xml/sax/InputSource.hpp>
-#include <com/sun/star/xml/sax/XDTDHandler.hpp>
-#include <com/sun/star/xml/sax/XParser.hpp>
-#include <com/sun/star/io/XActiveDataSource.hpp>
-#include <com/sun/star/io/XActiveDataControl.hpp>
-#include <com/sun/star/document/XDocumentProperties.hpp>
-#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
-#include <com/sun/star/packages/zip/ZipIOException.hpp>
-#include <com/sun/star/task/XStatusIndicatorFactory.hpp>
-#include <com/sun/star/beans/PropertyAttribute.hpp>
-#include <com/sun/star/container/XNameAccess.hpp>
-#include <com/sun/star/embed/ElementModes.hpp>
-#include <com/sun/star/uno/Any.h>
-
-#include <rtl/math.hxx>
-#include <sfx2/frame.hxx>
-#include <sfx2/docfile.hxx>
-#include <tools/debug.hxx>
-#include <tools/urlobj.hxx>
-#include <svtools/sfxecode.hxx>
-#include <svtools/saveopt.hxx>
-#include <svtools/stritem.hxx>
-#include <svtools/itemprop.hxx>
-#include <unotools/processfactory.hxx>
-#include <unotools/streamwrap.hxx>
-#include <xmloff/xmlnmspe.hxx>
-#include <xmloff/xmltoken.hxx>
-#include <xmloff/nmspmap.hxx>
-#include <xmloff/attrlist.hxx>
-#include <xmloff/xmluconv.hxx>
-#include <xmloff/xmlmetai.hxx>
-#include <osl/mutex.hxx>
-#include <comphelper/genericpropertyset.hxx>
-
-#include <memory>
-
-#include "mathmlexport.hxx"
-#include "mathtype.hxx"
-#include <starmath.hrc>
-#include <unomodel.hxx>
-#include <document.hxx>
-#include <utility.hxx>
-
-using namespace ::com::sun::star::beans;
-using namespace ::com::sun::star::container;
-using namespace ::com::sun::star::document;
-using namespace ::com::sun::star::lang;
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star;
-using namespace ::xmloff::token;
-
-using ::rtl::OUString;
-using ::rtl::OUStringBuffer;
-
-#define EXPORT_SVC_NAME RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.XMLExportFilter")
-
-#undef WANTEXCEPT
-
-
-////////////////////////////////////////////////////////////
-
-sal_Bool SmXMLExportWrapper::Export(SfxMedium &rMedium)
-{
- sal_Bool bRet=sal_True;
- uno::Reference<lang::XMultiServiceFactory>
- xServiceFactory(utl::getProcessServiceFactory());
- DBG_ASSERT(xServiceFactory.is(),"got no service manager");
-
- //Get model
- uno::Reference< lang::XComponent > xModelComp(xModel, uno::UNO_QUERY );
-
- sal_Bool bEmbedded = sal_False;
- uno::Reference <lang::XUnoTunnel> xTunnel;
- xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY);
- SmModel *pModel = reinterpret_cast<SmModel *>
- (xTunnel->getSomething(SmModel::getUnoTunnelId()));
-
- SmDocShell *pDocShell = pModel ?
- static_cast<SmDocShell*>(pModel->GetObjectShell()) : 0;
- if ( pDocShell &&
- SFX_CREATE_MODE_EMBEDDED == pDocShell->GetCreateMode() )
- bEmbedded = sal_True;
-
- uno::Reference<task::XStatusIndicator> xStatusIndicator;
- if (!bEmbedded)
- {
- if (pDocShell /*&& pDocShell->GetMedium()*/)
- {
- DBG_ASSERT( pDocShell->GetMedium() == &rMedium,
- "different SfxMedium found" );
-
- SfxItemSet* pSet = rMedium.GetItemSet();
- if (pSet)
- {
- const SfxUnoAnyItem* pItem = static_cast<const SfxUnoAnyItem*>(
- pSet->GetItem(SID_PROGRESS_STATUSBAR_CONTROL) );
- if (pItem)
- pItem->GetValue() >>= xStatusIndicator;
- }
- }
-
- // set progress range and start status indicator
- if (xStatusIndicator.is())
- {
- sal_Int32 nProgressRange = bFlat ? 1 : 3;
- xStatusIndicator->start(String(SmResId(STR_STATSTR_WRITING)),
- nProgressRange);
- }
- }
-
-
- // create XPropertySet with three properties for status indicator
- comphelper::PropertyMapEntry aInfoMap[] =
- {
- { "UsePrettyPrinting", sizeof("UsePrettyPrinting")-1, 0,
- &::getBooleanCppuType(),
- beans::PropertyAttribute::MAYBEVOID, 0},
- { "BaseURI", sizeof("BaseURI")-1, 0,
- &::getCppuType( (OUString *)0 ),
- beans::PropertyAttribute::MAYBEVOID, 0 },
- { "StreamRelPath", sizeof("StreamRelPath")-1, 0,
- &::getCppuType( (OUString *)0 ),
- beans::PropertyAttribute::MAYBEVOID, 0 },
- { "StreamName", sizeof("StreamName")-1, 0,
- &::getCppuType( (OUString *)0 ),
- beans::PropertyAttribute::MAYBEVOID, 0 },
- { NULL, 0, 0, NULL, 0, 0 }
- };
- uno::Reference< beans::XPropertySet > xInfoSet(
- comphelper::GenericPropertySet_CreateInstance(
- new comphelper::PropertySetInfo( aInfoMap ) ) );
-
- SvtSaveOptions aSaveOpt;
- OUString sUsePrettyPrinting(RTL_CONSTASCII_USTRINGPARAM("UsePrettyPrinting"));
- sal_Bool bUsePrettyPrinting( bFlat || aSaveOpt.IsPrettyPrinting() );
- Any aAny;
- aAny.setValue( &bUsePrettyPrinting, ::getBooleanCppuType() );
- xInfoSet->setPropertyValue( sUsePrettyPrinting, aAny );
-
- // Set base URI
- OUString sPropName( RTL_CONSTASCII_USTRINGPARAM("BaseURI") );
- xInfoSet->setPropertyValue( sPropName, makeAny( rMedium.GetBaseURL( true ) ) );
-
- sal_Int32 nSteps=0;
- if (xStatusIndicator.is())
- xStatusIndicator->setValue(nSteps++);
- if (!bFlat) //Storage (Package) of Stream
- {
- uno::Reference < embed::XStorage > xStg = rMedium.GetOutputStorage();
- sal_Bool bOASIS = ( SotStorage::GetVersion( xStg ) > SOFFICE_FILEFORMAT_60 );
-
- // TODO/LATER: handle the case of embedded links gracefully
- if ( bEmbedded ) //&& !pStg->IsRoot() )
- {
- OUString aName;
- if ( rMedium.GetItemSet() )
- {
- const SfxStringItem* pDocHierarchItem = static_cast<const SfxStringItem*>(
- rMedium.GetItemSet()->GetItem(SID_DOC_HIERARCHICALNAME) );
- if ( pDocHierarchItem )
- aName = pDocHierarchItem->GetValue();
- }
-
- if ( aName.getLength() )
- {
- sPropName = OUString(RTL_CONSTASCII_USTRINGPARAM("StreamRelPath"));
- xInfoSet->setPropertyValue( sPropName, makeAny( aName ) );
- }
- }
-
- if ( !bEmbedded )
- {
- if (xStatusIndicator.is())
- xStatusIndicator->setValue(nSteps++);
-
- bRet = WriteThroughComponent(
- xStg, xModelComp, "meta.xml", xServiceFactory, xInfoSet,
- (bOASIS ? "com.sun.star.comp.Math.XMLOasisMetaExporter"
- : "com.sun.star.comp.Math.XMLMetaExporter"),
- sal_False);
- }
- if ( bRet )
- {
- if (xStatusIndicator.is())
- xStatusIndicator->setValue(nSteps++);
-
- bRet = WriteThroughComponent(
- xStg, xModelComp, "content.xml", xServiceFactory, xInfoSet,
- "com.sun.star.comp.Math.XMLContentExporter");
- }
-
- if ( bRet )
- {
- if (xStatusIndicator.is())
- xStatusIndicator->setValue(nSteps++);
-
- bRet = WriteThroughComponent(
- xStg, xModelComp, "settings.xml", xServiceFactory, xInfoSet,
- (bOASIS ? "com.sun.star.comp.Math.XMLOasisSettingsExporter"
- : "com.sun.star.comp.Math.XMLSettingsExporter") );
- }
- }
- else
- {
- SvStream *pStream = rMedium.GetOutStream();
- uno::Reference<io::XOutputStream> xOut(
- new utl::OOutputStreamWrapper(*pStream) );
-
- if (xStatusIndicator.is())
- xStatusIndicator->setValue(nSteps++);
-
- bRet = WriteThroughComponent(
- xOut, xModelComp, xServiceFactory, xInfoSet,
- "com.sun.star.comp.Math.XMLContentExporter");
- }
-
- if (xStatusIndicator.is())
- xStatusIndicator->end();
-
- return bRet;
-}
-
-
-/// export through an XML exporter component (output stream version)
-sal_Bool SmXMLExportWrapper::WriteThroughComponent(
- Reference<io::XOutputStream> xOutputStream,
- Reference<XComponent> xComponent,
- Reference<lang::XMultiServiceFactory> & rFactory,
- Reference<beans::XPropertySet> & rPropSet,
- const sal_Char* pComponentName )
-{
- DBG_ASSERT(xOutputStream.is(), "I really need an output stream!");
- DBG_ASSERT(xComponent.is(), "Need component!");
- DBG_ASSERT(NULL != pComponentName, "Need component name!");
-
- // get component
- Reference< io::XActiveDataSource > xSaxWriter(
- rFactory->createInstance(
- OUString::createFromAscii("com.sun.star.xml.sax.Writer") ),
- UNO_QUERY );
- DBG_ASSERT( xSaxWriter.is(), "can't instantiate XML writer" );
- if (!xSaxWriter.is())
- return sal_False;
-
- // connect XML writer to output stream
- xSaxWriter->setOutputStream( xOutputStream );
-
- // prepare arguments (prepend doc handler to given arguments)
- Reference<xml::sax::XDocumentHandler> xDocHandler( xSaxWriter,UNO_QUERY);
-
- Sequence<Any> aArgs( 2 );
- aArgs[0] <<= xDocHandler;
- aArgs[1] <<= rPropSet;
-
- // get filter component
- Reference< document::XExporter > xExporter(
- rFactory->createInstanceWithArguments(
- OUString::createFromAscii(pComponentName), aArgs), UNO_QUERY);
- DBG_ASSERT( xExporter.is(),
- "can't instantiate export filter component" );
- if ( !xExporter.is() )
- return sal_False;
-
-
- // connect model and filter
- xExporter->setSourceDocument( xComponent );
-
- // filter!
- Reference < XFilter > xFilter( xExporter, UNO_QUERY );
- uno::Sequence< PropertyValue > aProps(0);
- xFilter->filter( aProps );
-
- uno::Reference<lang::XUnoTunnel> xFilterTunnel;
- xFilterTunnel = uno::Reference<lang::XUnoTunnel>
- ( xFilter, uno::UNO_QUERY );
- SmXMLExport *pFilter = reinterpret_cast< SmXMLExport * >(
- sal::static_int_cast< sal_uIntPtr >(
- xFilterTunnel->getSomething( SmXMLExport::getUnoTunnelId() )));
- return pFilter ? pFilter->GetSuccess() : sal_True;
-}
-
-
-/// export through an XML exporter component (storage version)
-sal_Bool SmXMLExportWrapper::WriteThroughComponent(
- const Reference < embed::XStorage >& xStorage,
- Reference<XComponent> xComponent,
- const sal_Char* pStreamName,
- Reference<lang::XMultiServiceFactory> & rFactory,
- Reference<beans::XPropertySet> & rPropSet,
- const sal_Char* pComponentName,
- sal_Bool bCompress
- )
-{
- DBG_ASSERT(xStorage.is(), "Need storage!");
- DBG_ASSERT(NULL != pStreamName, "Need stream name!");
-
- // open stream
- Reference < io::XStream > xStream;
- OUString sStreamName = OUString::createFromAscii(pStreamName);
- try
- {
- xStream = xStorage->openStreamElement( sStreamName,
- embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE );
- }
- catch ( uno::Exception& )
- {
- DBG_ERROR( "Can't create output stream in package!" );
- return sal_False;
- }
-
- String aPropName( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM("MediaType") ) );
- OUString aMime( RTL_CONSTASCII_USTRINGPARAM("text/xml") );
- uno::Any aAny;
- aAny <<= aMime;
-
- uno::Reference < beans::XPropertySet > xSet( xStream, uno::UNO_QUERY );
- xSet->setPropertyValue( aPropName, aAny );
-
- if ( !bCompress )
- {
- aPropName = String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM("Compressed") );
- sal_Bool bFalse = sal_False;
- aAny.setValue( &bFalse, ::getBooleanCppuType() );
- xSet->setPropertyValue( aPropName, aAny );
- }
-
- // even plain stream must be encrypted in encrypted document
- OUString aTmpPropName( RTL_CONSTASCII_USTRINGPARAM("UseCommonStoragePasswordEncryption") );
- sal_Bool bTrue = sal_True;
- aAny.setValue( &bTrue, ::getBooleanCppuType() );
- xSet->setPropertyValue( aTmpPropName, aAny );
-
- // set Base URL
- if ( rPropSet.is() )
- {
- OUString sPropName( RTL_CONSTASCII_USTRINGPARAM("StreamName") );
- rPropSet->setPropertyValue( sPropName, makeAny( sStreamName ) );
- }
-
- // write the stuff
- sal_Bool bRet = WriteThroughComponent( xStream->getOutputStream(), xComponent, rFactory,
- rPropSet, pComponentName );
-
- // stream is closed by SAX parser
- //if ( bRet )
- // xStream->getOutputStream()->closeOutput();
-
- return bRet;
-}
-
-////////////////////////////////////////////////////////////
-
-// #110680#
-SmXMLExport::SmXMLExport(
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
- sal_uInt16 nExportFlags)
-: SvXMLExport( xServiceFactory, MAP_INCH, XML_MATH, nExportFlags ) ,
- pTree(0) ,
- bSuccess(sal_False)
-{
-}
-
-sal_Int64 SAL_CALL SmXMLExport::getSomething(
- const uno::Sequence< sal_Int8 >& rId )
-throw(uno::RuntimeException)
-{
- if ( rId.getLength() == 16 &&
- 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
- rId.getConstArray(), 16 ) )
- return sal::static_int_cast< sal_Int64 >(reinterpret_cast< sal_uIntPtr >(this));
-
- return SvXMLExport::getSomething( rId );
-}
-
-const uno::Sequence< sal_Int8 > & SmXMLExport::getUnoTunnelId() throw()
-{
- static uno::Sequence< sal_Int8 > * pSeq = 0;
- if ( !pSeq )
- {
- osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
- if ( !pSeq )
- {
- static uno::Sequence< sal_Int8 > aSeq( 16 );
- rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
- pSeq = &aSeq;
- }
- }
- return *pSeq;
-}
-
-OUString SAL_CALL SmXMLExport_getImplementationName() throw()
-{
- return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLExporter" ) );
-}
-
-uno::Sequence< OUString > SAL_CALL SmXMLExport_getSupportedServiceNames()
- throw()
-{
- const OUString aServiceName( EXPORT_SVC_NAME );
- const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
- return aSeq;
-}
-
-uno::Reference< uno::XInterface > SAL_CALL SmXMLExport_createInstance(
- const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
- throw( uno::Exception )
-{
- // #110680#
- // return (cppu::OWeakObject*)new SmXMLExport( EXPORT_ALL );
- // EXPORT_OASIS is required here allthough there is no differrence between
- // OOo and OASIS, because without the flag, a transformation to OOo would
- // be chained in.
- return (cppu::OWeakObject*)new SmXMLExport( rSMgr, EXPORT_OASIS|EXPORT_ALL );
-}
-
-////////////////////////////////////////////////////////////
-
-OUString SAL_CALL SmXMLExportMetaOOO_getImplementationName() throw()
-{
- return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLMetaExporter" ) );
-}
-
-uno::Sequence< OUString > SAL_CALL SmXMLExportMetaOOO_getSupportedServiceNames()
- throw()
-{
- const OUString aServiceName( EXPORT_SVC_NAME );
- const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
- return aSeq;
-}
-
-uno::Reference< uno::XInterface > SAL_CALL SmXMLExportMetaOOO_createInstance(
- const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
-throw( uno::Exception )
-{
- // #110680#
- // return (cppu::OWeakObject*)new SmXMLExport( EXPORT_META );
- return (cppu::OWeakObject*)new SmXMLExport( rSMgr, EXPORT_META );
-}
-
-////////////////////////////////////////////////////////////
-
-OUString SAL_CALL SmXMLExportMeta_getImplementationName() throw()
-{
- return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLOasisMetaExporter" ) );
-}
-
-uno::Sequence< OUString > SAL_CALL SmXMLExportMeta_getSupportedServiceNames()
-throw()
-{
- const OUString aServiceName( EXPORT_SVC_NAME );
- const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
- return aSeq;
-}
-
-uno::Reference< uno::XInterface > SAL_CALL SmXMLExportMeta_createInstance(
- const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
-throw( uno::Exception )
-{
- // #110680#
- // return (cppu::OWeakObject*)new SmXMLExport( EXPORT_META );
- return (cppu::OWeakObject*)new SmXMLExport( rSMgr, EXPORT_OASIS|EXPORT_META );
-}
-
-////////////////////////////////////////////////////////////
-
-OUString SAL_CALL SmXMLExportSettingsOOO_getImplementationName() throw()
-{
- return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLSettingsExporter" ) );
-}
-
-uno::Sequence< OUString > SAL_CALL SmXMLExportSettingsOOO_getSupportedServiceNames()
-throw()
-{
- const OUString aServiceName( EXPORT_SVC_NAME );
- const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
- return aSeq;
-}
-
-uno::Reference< uno::XInterface > SAL_CALL SmXMLExportSettingsOOO_createInstance(
- const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
-throw( uno::Exception )
-{
- // #110680#
- // return (cppu::OWeakObject*)new SmXMLExport( EXPORT_SETTINGS );
- return (cppu::OWeakObject*)new SmXMLExport( rSMgr, EXPORT_SETTINGS );
-}
-
-////////////////////////////////////////////////////////////
-
-OUString SAL_CALL SmXMLExportSettings_getImplementationName() throw()
-{
- return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLOasisSettingsExporter" ) );
-}
-
-uno::Sequence< OUString > SAL_CALL SmXMLExportSettings_getSupportedServiceNames()
-throw()
-{
- const OUString aServiceName( EXPORT_SVC_NAME );
- const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
- return aSeq;
-}
-
-uno::Reference< uno::XInterface > SAL_CALL SmXMLExportSettings_createInstance(
- const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
-throw( uno::Exception )
-{
- // #110680#
- // return (cppu::OWeakObject*)new SmXMLExport( EXPORT_SETTINGS );
- return (cppu::OWeakObject*)new SmXMLExport( rSMgr, EXPORT_OASIS|EXPORT_SETTINGS );
-}
-
-////////////////////////////////////////////////////////////
-
-OUString SAL_CALL SmXMLExportContent_getImplementationName() throw()
-{
- return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLContentExporter" ) );
-}
-
-uno::Sequence< OUString > SAL_CALL SmXMLExportContent_getSupportedServiceNames()
- throw()
-{
- const OUString aServiceName( EXPORT_SVC_NAME );
- const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
- return aSeq;
-}
-
-uno::Reference< uno::XInterface > SAL_CALL SmXMLExportContent_createInstance(
- const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
-throw( uno::Exception )
-{
- // #110680#
- // return (cppu::OWeakObject*)new SmXMLExport( EXPORT_CONTENT );
- // The EXPORT_OASIS flag is only required to avoid that a transformer is
- // chanied in
- return (cppu::OWeakObject*)new SmXMLExport( rSMgr, EXPORT_OASIS|EXPORT_CONTENT );
-}
-
-////////////////////////////////////////////////////////////
-
-// XServiceInfo
-// override empty method from parent class
-rtl::OUString SAL_CALL SmXMLExport::getImplementationName()
-throw(uno::RuntimeException)
-{
- OUString aTxt;
- switch( getExportFlags() )
- {
- case EXPORT_META:
- aTxt = SmXMLExportMeta_getImplementationName();
- break;
- case EXPORT_SETTINGS:
- aTxt = SmXMLExportSettings_getImplementationName();
- break;
- case EXPORT_CONTENT:
- aTxt = SmXMLExportContent_getImplementationName();
- break;
- case EXPORT_ALL:
- default:
- aTxt = SmXMLExport_getImplementationName();
- break;
- }
- return aTxt;
-}
-
-sal_uInt32 SmXMLExport::exportDoc(enum XMLTokenEnum eClass)
-{
- if ( (getExportFlags() & EXPORT_CONTENT) == 0 )
- {
- SvXMLExport::exportDoc( eClass );
- }
- else
- {
- uno::Reference <frame::XModel> xModel = GetModel();
- uno::Reference <lang::XUnoTunnel> xTunnel;
- xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY);
- SmModel *pModel = reinterpret_cast<SmModel *>
- (xTunnel->getSomething(SmModel::getUnoTunnelId()));
-
- if (pModel)
- {
- SmDocShell *pDocShell =
- static_cast<SmDocShell*>(pModel->GetObjectShell());
- pTree = pDocShell->GetFormulaTree();
- aText = pDocShell->GetText();
- }
-
- GetDocHandler()->startDocument();
-
- /*Add xmlns line*/
- SvXMLAttributeList &rList = GetAttrList();
-
- // make use of a default namespace
- ResetNamespaceMap(); // Math doesn't need namespaces from xmloff, since it now uses default namespaces (because that is common with current MathML usage in the web)
- _GetNamespaceMap().Add( OUString::createFromAscii(""), GetXMLToken(XML_N_MATH), XML_NAMESPACE_MATH );
-
- rList.AddAttribute(GetNamespaceMap().GetAttrNameByKey(XML_NAMESPACE_MATH_IDX),
- GetNamespaceMap().GetNameByKey( XML_NAMESPACE_MATH_IDX));
-
- //I think we need something like ImplExportEntities();
- _ExportContent();
- GetDocHandler()->endDocument();
- }
-
- bSuccess=sal_True;
- return 0;
-}
-
-void SmXMLExport::_ExportContent()
-{
- SvXMLElementExport aEquation(*this, XML_NAMESPACE_MATH, XML_MATH, sal_True, sal_True);
- SvXMLElementExport *pSemantics=0;
-
- if (aText.Len())
- {
- pSemantics = new SvXMLElementExport(*this, XML_NAMESPACE_MATH,
- XML_SEMANTICS, sal_True, sal_True);
- }
-
- ExportNodes(pTree, 0);
-
- if (aText.Len())
- {
- // Convert symbol names
- uno::Reference <frame::XModel> xModel = GetModel();
- uno::Reference <lang::XUnoTunnel> xTunnel;
- xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY);
- SmModel *pModel = reinterpret_cast<SmModel *>
- (xTunnel->getSomething(SmModel::getUnoTunnelId()));
- SmDocShell *pDocShell = pModel ?
- static_cast<SmDocShell*>(pModel->GetObjectShell()) : 0;
- DBG_ASSERT( pDocShell, "doc shell missing" );
- if (pDocShell)
- {
- SmParser &rParser = pDocShell->GetParser();
- BOOL bVal = rParser.IsExportSymbolNames();
- rParser.SetExportSymbolNames( TRUE );
- SmNode *pTmpTree = rParser.Parse( aText );
- aText = rParser.GetText();
- delete pTmpTree;
- rParser.SetExportSymbolNames( bVal );
- }
-
- AddAttribute(XML_NAMESPACE_MATH, XML_ENCODING,
- OUString(RTL_CONSTASCII_USTRINGPARAM("StarMath 5.0")));
- SvXMLElementExport aAnnotation(*this, XML_NAMESPACE_MATH,
- XML_ANNOTATION, sal_True, sal_False);
- GetDocHandler()->characters(OUString( aText ));
- }
- delete pSemantics;
-}
-
-void SmXMLExport::GetViewSettings( Sequence < PropertyValue >& aProps)
-{
- uno::Reference <frame::XModel> xModel = GetModel();
- if ( !xModel.is() )
- return;
-
- uno::Reference <lang::XUnoTunnel> xTunnel;
- xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY);
- SmModel *pModel = reinterpret_cast<SmModel *>
- (xTunnel->getSomething(SmModel::getUnoTunnelId()));
-
- if ( !pModel )
- return;
-
- SmDocShell *pDocShell =
- static_cast<SmDocShell*>(pModel->GetObjectShell());
- if ( !pDocShell )
- return;
-
- aProps.realloc( 4 );
- PropertyValue *pValue = aProps.getArray();
- sal_Int32 nIndex = 0;
-
- Rectangle aRect( pDocShell->GetVisArea() );
-
- pValue[nIndex].Name = OUString( RTL_CONSTASCII_USTRINGPARAM ( "ViewAreaTop") );
- pValue[nIndex++].Value <<= aRect.Top();
-
- pValue[nIndex].Name = OUString( RTL_CONSTASCII_USTRINGPARAM ( "ViewAreaLeft") );
- pValue[nIndex++].Value <<= aRect.Left();
-
- pValue[nIndex].Name = OUString( RTL_CONSTASCII_USTRINGPARAM ( "ViewAreaWidth") );
- pValue[nIndex++].Value <<= aRect.GetWidth();
-
- pValue[nIndex].Name = OUString( RTL_CONSTASCII_USTRINGPARAM ( "ViewAreaHeight") );
- pValue[nIndex++].Value <<= aRect.GetHeight();
-}
-
-void SmXMLExport::GetConfigurationSettings( Sequence < PropertyValue > & rProps)
-{
- Reference < XPropertySet > xProps ( GetModel(), UNO_QUERY );
- if ( xProps.is() )
- {
- Reference< XPropertySetInfo > xPropertySetInfo = xProps->getPropertySetInfo();
- if (xPropertySetInfo.is())
- {
- Sequence< Property > aProps = xPropertySetInfo->getProperties();
- sal_Int32 nCount(aProps.getLength());
- if (nCount > 0)
- {
- rProps.realloc(nCount);
- PropertyValue* pProps = rProps.getArray();
- if (pProps)
- {
- const OUString sFormula ( RTL_CONSTASCII_USTRINGPARAM ( "Formula" ) );
- const OUString sBasicLibraries ( RTL_CONSTASCII_USTRINGPARAM ( "BasicLibraries" ) );
- const OUString sDialogLibraries ( RTL_CONSTASCII_USTRINGPARAM ( "DialogLibraries" ) );
- const OUString sRuntimeUID ( RTL_CONSTASCII_USTRINGPARAM ( "RuntimeUID" ) );
- for (sal_Int32 i = 0; i < nCount; i++, pProps++)
- {
- const OUString &rPropName = aProps[i].Name;
- if (rPropName != sFormula &&
- rPropName != sBasicLibraries &&
- rPropName != sDialogLibraries &&
- rPropName != sRuntimeUID)
- {
- pProps->Name = rPropName;
- pProps->Value = xProps->getPropertyValue(rPropName);
- }
- }
- }
- }
- }
- }
-}
-
-void SmXMLExport::ExportLine(const SmNode *pNode, int nLevel)
-{
- ExportExpression(pNode, nLevel);
-}
-
-void SmXMLExport::ExportBinaryHorizontal(const SmNode *pNode, int nLevel)
-{
- ExportExpression(pNode, nLevel);
-}
-
-void SmXMLExport::ExportUnaryHorizontal(const SmNode *pNode, int nLevel)
-{
- ExportExpression(pNode, nLevel);
-}
-
-void SmXMLExport::ExportExpression(const SmNode *pNode, int nLevel)
-{
- SvXMLElementExport *pRow=0;
- ULONG nSize = pNode->GetNumSubNodes();
-
- if (nSize > 1)
- pRow = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MROW, sal_True, sal_True);
-
- //if (nSize)
- //{
- for (USHORT i = 0; i < nSize; i++)
- if (const SmNode *pTemp = pNode->GetSubNode(i))
- ExportNodes(pTemp, nLevel+1);
- //}
-#if 0
- else
- {
- //This saves us from situations like "a newline" where the
- //lack of a term following the newline would otherwise create
- //a incorrect token like <mtr/>
- SvXMLElementExport aDummy(*this, XML_NAMESPACE_MATH, XML_MI, sal_True, sal_False);
- sal_Unicode nArse[2] = {'\n','\0'};
- GetDocHandler()->characters(nArse);
- }
-#endif
-
- delete pRow;
-}
-
-void SmXMLExport::ExportBinaryVertical(const SmNode *pNode, int nLevel)
-{
- DBG_ASSERT(pNode->GetNumSubNodes()==3,"Bad Fraction");
- SvXMLElementExport aFraction(*this, XML_NAMESPACE_MATH, XML_MFRAC, sal_True, sal_True);
- ExportNodes(pNode->GetSubNode(0), nLevel);
- ExportNodes(pNode->GetSubNode(2), nLevel);
-}
-
-void SmXMLExport::ExportTable(const SmNode *pNode, int nLevel)
-{
- SvXMLElementExport *pTable=0;
-
- USHORT nSize = pNode->GetNumSubNodes();
-
- //If the list ends in newline then the last entry has
- //no subnodes, the newline is superfulous so we just drop
- //the last node, inclusion would create a bad MathML
- //table
- if (nSize >= 1 && pNode->GetSubNode(nSize-1)->GetNumSubNodes() == 0)
- --nSize;
-
- // try to avoid creating a mtable element when the formula consists only
- // of a single output line
- if (nLevel || (nSize >1))
- pTable = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MTABLE, sal_True, sal_True);
-
- for (USHORT i = 0; i < nSize; i++)
- if (const SmNode *pTemp = pNode->GetSubNode(i))
- {
- SvXMLElementExport *pRow=0;
- SvXMLElementExport *pCell=0;
- if (pTable)
- {
- pRow = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MTR, sal_True, sal_True);
- pCell = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MTD, sal_True, sal_True);
- }
- ExportNodes(pTemp, nLevel+1);
- delete pCell;
- delete pRow;
- }
-
- delete pTable;
-}
-
-void SmXMLExport::ExportMath(const SmNode *pNode, int /*nLevel*/)
-{
- const SmMathSymbolNode *pTemp = static_cast<const SmMathSymbolNode *>(pNode);
- SvXMLElementExport aMath(*this, XML_NAMESPACE_MATH, XML_MO, sal_True, sal_False);
- sal_Unicode nArse[2];
- nArse[0] = pTemp->GetText().GetChar(0);
- sal_Unicode cTmp = ConvertMathToMathML( nArse[0] );
- if (cTmp != 0)
- nArse[0] = cTmp;
- DBG_ASSERT(nArse[0] != 0xffff,"Non existant symbol");
- nArse[1] = 0;
- GetDocHandler()->characters(nArse);
-}
-
-void SmXMLExport::ExportText(const SmNode *pNode, int /*nLevel*/)
-{
- SvXMLElementExport *pText;
- const SmTextNode *pTemp = static_cast<const SmTextNode *>(pNode);
- switch (pNode->GetToken().eType)
- {
- default:
- case TIDENT:
- {
- //Note that we change the fontstyle to italic for strings that
- //are italic and longer than a single character.
- sal_Bool bIsItalic = IsItalic( pTemp->GetFont() );
- if ((pTemp->GetText().Len() > 1) && bIsItalic)
- AddAttribute(XML_NAMESPACE_MATH, XML_MATHVARIANT, XML_ITALIC);
- else if ((pTemp->GetText().Len() == 1) && !bIsItalic)
- AddAttribute(XML_NAMESPACE_MATH, XML_MATHVARIANT, XML_NORMAL);
- pText = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MI,sal_True,sal_False);
- break;
- }
- case TNUMBER:
- pText = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MN,sal_True,sal_False);
- break;
- case TTEXT:
- pText = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MTEXT,sal_True,sal_False);
- break;
- }
- GetDocHandler()->characters(OUString(pTemp->GetText().GetBuffer()));
- delete pText;
-}
-
-void SmXMLExport::ExportBlank(const SmNode * /*pNode*/, int /*nLevel*/)
-{
- //!! exports an empty <mi> tag since for example "~_~" is allowed in
- //!! Math (so it has no sense at all) but must not result in an empty
- //!! <msub> tag in MathML !!
-
- SvXMLElementExport *pText;
- //const SmBlankNode *pTemp = static_cast<const SmBlankNode *>(pNode);
-
- pText = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MI, sal_True, sal_False);
-
- GetDocHandler()->characters( OUString() );
- delete pText;
-}
-
-void SmXMLExport::ExportSubSupScript(const SmNode *pNode, int nLevel)
-{
- const SmNode *pSub = 0;
- const SmNode *pSup = 0;
- const SmNode *pCSub = 0;
- const SmNode *pCSup = 0;
- const SmNode *pLSub = 0;
- const SmNode *pLSup = 0;
- SvXMLElementExport *pThing = 0, *pThing2 = 0;
-
- //if we have prescripts at all then we must use the tensor notation
-
- //This is one of those excellent locations where scope is vital to
- //arrange the construction and destruction of the element helper
- //classes correctly
- pLSub = pNode->GetSubNode(LSUB+1);
- pLSup = pNode->GetSubNode(LSUP+1);
- if (pLSub || pLSup)
- {
- SvXMLElementExport aMultiScripts(*this, XML_NAMESPACE_MATH,
- XML_MMULTISCRIPTS, sal_True, sal_True);
-
-
- if (NULL != (pCSub = pNode->GetSubNode(CSUB+1))
- && NULL != (pCSup = pNode->GetSubNode(CSUP+1)))
- {
- pThing2 = new SvXMLElementExport(*this, XML_NAMESPACE_MATH,
- XML_MUNDEROVER, sal_True,sal_True);
- }
- else if (NULL != (pCSub = pNode->GetSubNode(CSUB+1)))
- {
- pThing2 = new SvXMLElementExport(*this, XML_NAMESPACE_MATH,
- XML_MUNDER, sal_True,sal_True);
- }
- else if (NULL != (pCSup = pNode->GetSubNode(CSUP+1)))
- {
- pThing2 = new SvXMLElementExport(*this, XML_NAMESPACE_MATH,
- XML_MOVER, sal_True,sal_True);
- }
-
- ExportNodes(pNode->GetSubNode(0), nLevel+1); //Main Term
-
- if (pCSub)
- ExportNodes(pCSub, nLevel+1);
- if (pCSup)
- ExportNodes(pCSup, nLevel+1);
- delete pThing2;
-
- pSub = pNode->GetSubNode(RSUB+1);
- pSup = pNode->GetSubNode(RSUP+1);
- if (pSub || pSup)
- {
- if (pSub)
- ExportNodes(pSub, nLevel+1);
- else
- {
- SvXMLElementExport aNone(*this, XML_NAMESPACE_MATH, XML_NONE,sal_True,sal_True);
- }
- if (pSup)
- ExportNodes(pSup, nLevel+1);
- else
- {
- SvXMLElementExport aNone(*this, XML_NAMESPACE_MATH, XML_NONE,sal_True,sal_True);
- }
- }
-
- //Seperator element between suffix and prefix sub/sup pairs
- {
- SvXMLElementExport aPrescripts(*this, XML_NAMESPACE_MATH,
- XML_MPRESCRIPTS, sal_True,sal_True);
- }
-
- if (pLSub)
- ExportNodes(pLSub, nLevel+1);
- else
- {
- SvXMLElementExport aNone(*this, XML_NAMESPACE_MATH, XML_NONE,
- sal_True,sal_True);
-
- }
- if (pLSup)
- ExportNodes(pLSup, nLevel+1);
- else
- {
- SvXMLElementExport aNone(*this, XML_NAMESPACE_MATH, XML_NONE,
- sal_True,sal_True);
-
- }
- }
- else
- {
- if (NULL != (pSub = pNode->GetSubNode(RSUB+1)) &&
- NULL != (pSup = pNode->GetSubNode(RSUP+1)))
- {
- pThing = new SvXMLElementExport(*this, XML_NAMESPACE_MATH,
- XML_MSUBSUP, sal_True,sal_True);
- }
- else if (NULL != (pSub = pNode->GetSubNode(RSUB+1)))
- {
- pThing = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MSUB,
- sal_True,sal_True);
- }
- else if (NULL != (pSup = pNode->GetSubNode(RSUP+1)))
- {
- pThing = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MSUP,
- sal_True,sal_True);
- }
-
- if (NULL != (pCSub = pNode->GetSubNode(CSUB+1))
- && NULL != (pCSup=pNode->GetSubNode(CSUP+1)))
- {
- pThing2 = new SvXMLElementExport(*this, XML_NAMESPACE_MATH,
- XML_MUNDEROVER, sal_True,sal_True);
- }
- else if (NULL != (pCSub = pNode->GetSubNode(CSUB+1)))
- {
- pThing2 = new SvXMLElementExport(*this, XML_NAMESPACE_MATH,
- XML_MUNDER, sal_True,sal_True);
- }
- else if (NULL != (pCSup = pNode->GetSubNode(CSUP+1)))
- {
- pThing2 = new SvXMLElementExport(*this, XML_NAMESPACE_MATH,
- XML_MOVER, sal_True,sal_True);
- }
- ExportNodes(pNode->GetSubNode(0), nLevel+1); //Main Term
-
- if (pCSub)
- ExportNodes(pCSub, nLevel+1);
- if (pCSup)
- ExportNodes(pCSup, nLevel+1);
- delete pThing2;
-
- if (pSub)
- ExportNodes(pSub, nLevel+1);
- if (pSup)
- ExportNodes(pSup, nLevel+1);
- delete pThing;
- }
-}
-
-void SmXMLExport::ExportBrace(const SmNode *pNode, int nLevel)
-{
- const SmNode *pTemp;
- const SmNode *pLeft=pNode->GetSubNode(0);
- const SmNode *pRight=pNode->GetSubNode(2);
- SvXMLElementExport *pFences=0,*pRow=0;
- if ( ((pLeft) && (pLeft->GetToken().eType != TNONE)) &&
- ((pRight) && (pRight->GetToken().eType != TNONE)) &&
- (pNode->GetScaleMode() == SCALE_HEIGHT))
- {
- sal_Unicode nArse[2];
- nArse[1] = 0;
- nArse[0] = static_cast<
- const SmMathSymbolNode* >(pLeft)->GetText().GetChar(0);
- DBG_ASSERT(nArse[0] != 0xffff,"Non existant symbol");
- AddAttribute(XML_NAMESPACE_MATH, XML_OPEN,nArse);
- nArse[0] = static_cast<
- const SmMathSymbolNode* >(pRight)->GetText().GetChar(0);
- DBG_ASSERT(nArse[0] != 0xffff,"Non existant symbol");
- AddAttribute(XML_NAMESPACE_MATH, XML_CLOSE,nArse);
- pFences = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MFENCED,
- sal_True,sal_True);
- }
- else if (pLeft && (pLeft->GetToken().eType != TNONE))
- {
- pRow = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MROW,
- sal_True, sal_True);
- if (pNode->GetScaleMode() == SCALE_HEIGHT)
- AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_TRUE);
- else
- AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_FALSE);
- ExportNodes(pLeft, nLevel+1);
- }
- else
- pRow = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MROW,
- sal_True, sal_True);
-
- if (NULL != (pTemp = pNode->GetSubNode(1)))
- ExportNodes(pTemp, nLevel+1);
- if (pFences)
- delete pFences;
- else if (pRight && (pRight->GetToken().eType != TNONE))
- {
- if (pNode->GetScaleMode() == SCALE_HEIGHT)
- AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_TRUE);
- else
- AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_FALSE);
- ExportNodes(pRight, nLevel+1);
- }
- delete pRow;
-}
-
-void SmXMLExport::ExportRoot(const SmNode *pNode, int nLevel)
-{
- if (pNode->GetSubNode(0))
- {
- SvXMLElementExport aRoot(*this, XML_NAMESPACE_MATH, XML_MROOT,sal_True,
- sal_True);
- ExportNodes(pNode->GetSubNode(2), nLevel+1);
- ExportNodes(pNode->GetSubNode(0), nLevel+1);
- }
- else
- {
- SvXMLElementExport aSqrt(*this, XML_NAMESPACE_MATH, XML_MSQRT,sal_True,
- sal_True);
- ExportNodes(pNode->GetSubNode(2), nLevel+1);
- }
-}
-
-void SmXMLExport::ExportOperator(const SmNode *pNode, int nLevel)
-{
- /*we need to either use content or font and size attributes
- *here*/
-#if 0
- {
- SvXMLElementExport aMath(*this, XML_NAMESPACE_MATH, XML_MO,
- sal_True,sal_False);
- SmTextNode *pTemp = (SmTextNode *)pNode->GetSubNode(0);
- GetDocHandler()->characters(pTemp->GetText());
- }
-#endif
- SvXMLElementExport aRow(*this, XML_NAMESPACE_MATH, XML_MROW,
- sal_True, sal_True);
- ExportNodes(pNode->GetSubNode(0), nLevel+1);
- ExportNodes(pNode->GetSubNode(1), nLevel+1);
-}
-
-void SmXMLExport::ExportAttributes(const SmNode *pNode, int nLevel)
-{
- SvXMLElementExport *pElement=0;
-
- if (pNode->GetToken().eType == TUNDERLINE)
- {
- AddAttribute(XML_NAMESPACE_MATH, XML_ACCENTUNDER,
- XML_TRUE);
- pElement = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MUNDER,
- sal_True,sal_True);
- }
- else if (pNode->GetToken().eType != TOVERSTRIKE)
- {
- AddAttribute(XML_NAMESPACE_MATH, XML_ACCENT,
- XML_TRUE);
- pElement = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MOVER,
- sal_True,sal_True);
- }
-
- ExportNodes(pNode->GetSubNode(1), nLevel+1);
- switch (pNode->GetToken().eType)
- {
- case TOVERLINE:
- {
- //proper entity support required
- SvXMLElementExport aMath(*this, XML_NAMESPACE_MATH, XML_MO,
- sal_True,sal_True);
-#if 0
- GetDocHandler()->characters(
- OUString(RTL_CONSTASCII_USTRINGPARAM("&overbar;")));
-#else
- sal_Unicode nArse[2] = {0xAF,0x00};
-#endif
- GetDocHandler()->characters(nArse);
- }
- break;
- case TUNDERLINE:
- {
- //proper entity support required
- SvXMLElementExport aMath(*this, XML_NAMESPACE_MATH, XML_MO,
- sal_True,sal_True);
-#if 0
- GetDocHandler()->characters(
- OUString(RTL_CONSTASCII_USTRINGPARAM("&underbar;")));
-#else
- sal_Unicode nArse[2] = {0x0332,0x00};
-#endif
- GetDocHandler()->characters(nArse);
- }
- break;
- case TOVERSTRIKE:
- break;
- default:
- ExportNodes(pNode->GetSubNode(0), nLevel+1);
- break;
- }
- delete pElement;
-}
-
-static bool lcl_HasEffectOnMathvariant( const SmTokenType eType )
-{
- return eType == TBOLD || eType == TNBOLD ||
- eType == TITALIC || eType == TNBOLD ||
- eType == TSANS || eType == TSERIF || eType == TFIXED;
-}
-
-void SmXMLExport::ExportFont(const SmNode *pNode, int nLevel)
-{
- SvXMLElementExport *pElement = 0;
-
- //
- // gather the mathvariant attribut relevant data from all
- // successively following SmFontNodes...
- //
- int nBold = -1; // for the following variables: -1 = yet undefined; 0 = false; 1 = true;
- int nItalic = -1; // for the following variables: -1 = yet undefined; 0 = false; 1 = true;
- int nSansSerifFixed = -1;
- SmTokenType eNodeType = TUNKNOWN;
- while (lcl_HasEffectOnMathvariant( (eNodeType = pNode->GetToken().eType) ))
- {
- switch (eNodeType)
- {
- case TBOLD : nBold = 1; break;
- case TNBOLD : nBold = 0; break;
- case TITALIC : nItalic = 1; break;
- case TNITALIC : nItalic = 0; break;
- case TSANS : nSansSerifFixed = 0; break;
- case TSERIF : nSansSerifFixed = 1; break;
- case TFIXED : nSansSerifFixed = 2; break;
- default:
- DBG_ASSERT( 0, "unexpected case" );
- }
- // According to the parser every node that is to be evaluated heres
- // has a single non-zero subnode at index 1!! Thus we only need to check
- // that single node for follow-up nodes that have an effect on the attribute.
- if (pNode->GetNumSubNodes() > 1 && pNode->GetSubNode(1) &&
- lcl_HasEffectOnMathvariant( pNode->GetSubNode(1)->GetToken().eType))
- {
- pNode = pNode->GetSubNode(1);
- }
- else
- break;
- }
-
- switch (pNode->GetToken().eType)
- {
- //wrap a phantom element around everything*/
- case TPHANTOM:
- pElement = new SvXMLElementExport(*this, XML_NAMESPACE_MATH,
- XML_MPHANTOM, sal_True,sal_True);
- break;
- case TBLACK:
- AddAttribute(XML_NAMESPACE_MATH, XML_COLOR, XML_BLACK);
- break;
- case TWHITE:
- AddAttribute(XML_NAMESPACE_MATH, XML_COLOR, XML_WHITE);
- break;
- case TRED:
- AddAttribute(XML_NAMESPACE_MATH, XML_COLOR, XML_RED);
- break;
- case TGREEN:
- AddAttribute(XML_NAMESPACE_MATH, XML_COLOR, XML_GREEN);
- break;
- case TBLUE:
- AddAttribute(XML_NAMESPACE_MATH, XML_COLOR, XML_BLUE);
- break;
- case TCYAN:
- AddAttribute(XML_NAMESPACE_MATH, XML_COLOR, XML_AQUA);
- break;
- case TMAGENTA:
- AddAttribute(XML_NAMESPACE_MATH, XML_COLOR, XML_FUCHSIA);
- break;
- case TYELLOW:
- AddAttribute(XML_NAMESPACE_MATH, XML_COLOR, XML_YELLOW);
- break;
- case TSIZE:
- {
- const SmFontNode *pFontNode = static_cast<const SmFontNode *>(pNode);
- const Fraction &aFrac = pFontNode->GetSizeParameter();
-
- OUStringBuffer sStrBuf;
- switch(pFontNode->GetSizeType())
- {
- case FNTSIZ_MULTIPLY:
- SvXMLUnitConverter::convertDouble(sStrBuf,
- static_cast<double>(aFrac*Fraction(100.00)));
- sStrBuf.append(static_cast<sal_Unicode>('%'));
- break;
- case FNTSIZ_DIVIDE:
- SvXMLUnitConverter::convertDouble(sStrBuf,
- static_cast<double>(Fraction(100.00)/aFrac));
- sStrBuf.append(static_cast<sal_Unicode>('%'));
- break;
- case FNTSIZ_ABSOLUT:
- SvXMLUnitConverter::convertDouble(sStrBuf,
- static_cast<double>(aFrac));
- sStrBuf.append(
- GetXMLToken(XML_UNIT_PT));
- break;
- default:
- {
- //The problem here is that the wheels fall off because
- //font size is stored in 100th's of a mm not pts, and
- //rounding errors take their toll on the original
- //value specified in points.
-
- //Must fix StarMath to retain the original pt values
- Fraction aTemp = Sm100th_mmToPts(pFontNode->GetFont().
- GetSize().Height());
-
- if (pFontNode->GetSizeType() == FNTSIZ_MINUS)
- aTemp-=aFrac;
- else
- aTemp+=aFrac;
-
- double mytest = static_cast<double>(aTemp);
-
- mytest = ::rtl::math::round(mytest,1);
- SvXMLUnitConverter::convertDouble(sStrBuf,mytest);
- sStrBuf.append(GetXMLToken(XML_UNIT_PT));
- }
- break;
- }
-
- OUString sStr(sStrBuf.makeStringAndClear());
- AddAttribute(XML_NAMESPACE_MATH, XML_MATHSIZE, sStr);
- }
- break;
- case TBOLD:
- case TITALIC:
- case TNBOLD:
- case TNITALIC:
- case TFIXED:
- case TSANS:
- case TSERIF:
- {
- // nBold: -1 = yet undefined; 0 = false; 1 = true;
- // nItalic: -1 = yet undefined; 0 = false; 1 = true;
- // nSansSerifFixed: -1 = undefined; 0 = sans; 1 = serif; 2 = fixed;
- const sal_Char *pText = "normal";
- if (nSansSerifFixed == -1 || nSansSerifFixed == 1)
- {
- pText = "normal";
- if (nBold == 1 && nItalic != 1)
- pText = "bold";
- else if (nBold != 1 && nItalic == 1)
- pText = "italic";
- else if (nBold == 1 && nItalic == 1)
- pText = "bold-italic";
- }
- else if (nSansSerifFixed == 0)
- {
- pText = "sans-serif";
- if (nBold == 1 && nItalic != 1)
- pText = "bold-sans-serif";
- else if (nBold != 1 && nItalic == 1)
- pText = "sans-serif-italic";
- else if (nBold == 1 && nItalic == 1)
- pText = "sans-serif-bold-italic";
- }
- else if (nSansSerifFixed == 2)
- pText = "monospace"; // no modifiers allowed for monospace ...
- else
- {
- DBG_ASSERT( 0, "unexpected case" );
- }
- AddAttribute(XML_NAMESPACE_MATH, XML_MATHVARIANT, A2OU(pText));
- }
- break;
- default:
- break;
-
- }
-#if 0
- if (pNode->GetNumSubNodes() > 1) //or in the future is a node that
- //cannot take the currently supported
- //properties
-#endif
- //for now we will just always export with a style and not worry about
- //anyone else for the moment.
- {
- //wrap a style around it
- SvXMLElementExport aStyle(*this, XML_NAMESPACE_MATH, XML_MSTYLE, sal_True,sal_True);
- ExportExpression(pNode, nLevel);
- }
-#if 0
- else
- ExportNodes(pNode->GetSubNode(0), nLevel+1);
-#endif
-
- delete pElement;
-}
-
-
-void SmXMLExport::ExportVerticalBrace(const SmNode *pNode, int nLevel)
-{
- //Place the overbrace value OVER a vertical brace and then place that
- //expression OVER the overbrace value, If someone can find a
- //dedicated term in MathML to handle this overbrace/underbrace concept
- //let me know. C.
- XMLTokenEnum which;
-
- switch (pNode->GetToken().eType)
- {
- case TOVERBRACE:
- default:
- which = XML_MOVER;
- break;
- case TUNDERBRACE:
- which = XML_MUNDER;
- break;
- }
-
- DBG_ASSERT(pNode->GetNumSubNodes()==3,"Bad Vertical Brace");
- SvXMLElementExport aOver1(*this, XML_NAMESPACE_MATH,which, sal_True, sal_True);
- {//Scoping
- // using accents will draw the over-/underbraces too close to the base
- // see http://www.w3.org/TR/MathML2/chapter3.html#id.3.4.5.2
- // also XML_ACCENT is illegal with XML_MUNDER. Thus no XML_ACCENT attribut here!
-// AddAttribute(XML_NAMESPACE_MATH, XML_ACCENT, XML_TRUE);
- SvXMLElementExport aOver2(*this, XML_NAMESPACE_MATH,which, sal_True, sal_True);
- ExportNodes(pNode->GetSubNode(0), nLevel);
- ExportNodes(pNode->GetSubNode(1), nLevel);
- }
- ExportNodes(pNode->GetSubNode(2), nLevel);
-}
-
-void SmXMLExport::ExportMatrix(const SmNode *pNode, int nLevel)
-{
- SvXMLElementExport aTable(*this, XML_NAMESPACE_MATH, XML_MTABLE, sal_True, sal_True);
- const SmMatrixNode *pMatrix = static_cast<const SmMatrixNode *>(pNode);
- USHORT i=0;
- for (ULONG y = 0; y < pMatrix->GetNumRows(); y++)
- {
- SvXMLElementExport aRow(*this, XML_NAMESPACE_MATH, XML_MTR, sal_True, sal_True);
- for (ULONG x = 0; x < pMatrix->GetNumCols(); x++)
- if (const SmNode *pTemp = pNode->GetSubNode(i++))
- {
- SvXMLElementExport aCell(*this, XML_NAMESPACE_MATH, XML_MTD, sal_True, sal_True);
- ExportNodes(pTemp, nLevel+1);
- }
- }
-}
-
-void SmXMLExport::ExportNodes(const SmNode *pNode, int nLevel)
-{
- if (!pNode)
- return;
- switch(pNode->GetType())
- {
- case NTABLE:
- ExportTable(pNode, nLevel);
- break;
- case NALIGN:
- case NBRACEBODY:
- case NEXPRESSION:
- ExportExpression(pNode, nLevel);
- break;
- case NLINE:
- ExportLine(pNode, nLevel);
- break;
- case NTEXT:
- ExportText(pNode, nLevel);
- break;
- case NSPECIAL: //NSPECIAL requires some sort of Entity preservation in the XML engine.
- case NGLYPH_SPECIAL:
- case NMATH:
- {
- sal_Unicode cTmp = 0;
- const SmTextNode *pTemp = static_cast< const SmTextNode * >(pNode);
- if (pTemp->GetText().Len() > 0)
- cTmp = ConvertMathToMathML( pTemp->GetText().GetChar(0) );
- if (cTmp == 0)
- {
- // no conversion to MathML implemented -> export it as text
- // thus at least it will not vanish into nothing
- ExportText(pNode, nLevel);
- }
- else
- {
- //To fully handle generic MathML we need to implement the full
- //operator dictionary, we will generate MathML with explicit
- //stretchiness for now.
- sal_Int16 nLength = GetAttrList().getLength();
- sal_Bool bAddStretch=sal_True;
- for ( sal_Int16 i = 0; i < nLength; i++ )
- {
- OUString sLocalName;
- sal_uInt16 nPrefix = GetNamespaceMap().GetKeyByAttrName(
- GetAttrList().getNameByIndex(i), &sLocalName );
-
- if ( ( XML_NAMESPACE_MATH == nPrefix ) &&
- IsXMLToken(sLocalName, XML_STRETCHY) )
- {
- bAddStretch = sal_False;
- break;
- }
- }
- if (bAddStretch)
- {
- AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_FALSE);
- }
- ExportMath(pNode, nLevel);
- }
- }
- break;
- case NPLACE:
- ExportMath(pNode, nLevel);
- break;
- case NBINHOR:
- ExportBinaryHorizontal(pNode, nLevel);
- break;
- case NUNHOR:
- ExportUnaryHorizontal(pNode, nLevel);
- break;
- case NBRACE:
- ExportBrace(pNode, nLevel);
- break;
- case NBINVER:
- ExportBinaryVertical(pNode, nLevel);
- break;
- case NSUBSUP:
- ExportSubSupScript(pNode, nLevel);
- break;
- case NROOT:
- ExportRoot(pNode, nLevel);
- break;
- case NOPER:
- ExportOperator(pNode, nLevel);
- break;
- case NATTRIBUT:
- ExportAttributes(pNode, nLevel);
- break;
- case NFONT:
- ExportFont(pNode, nLevel);
- break;
- case NVERTICAL_BRACE:
- ExportVerticalBrace(pNode, nLevel);
- break;
- case NMATRIX:
- ExportMatrix(pNode, nLevel);
- break;
- case NBLANK:
- ExportBlank(pNode, nLevel);
- break;
- default:
- DBG_ASSERT( 0, "Warning: failed to export a node?" );
- break;
-
-#if 0
- default:
- {
- ULONG nSize = pNode->GetNumSubNodes();
- for (ULONG i = 0; i < nSize; i++)
- if (SmNode *pTemp = pNode->GetSubNode(i))
- ExportNodes(pTemp, nLevel+1);
- }
- break;
-#endif
- }
-}
-
-////////////////////////////////////////////////////////////
-
+/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_starmath.hxx" + +/* + Warning: The SvXMLElementExport helper class creates the beginning and + closing tags of xml elements in its constructor and destructor, so theres + hidden stuff going on, on occasion the ordering of these classes declarations + may be significant +*/ + + +#include <com/sun/star/xml/sax/XErrorHandler.hpp> +#include <com/sun/star/xml/sax/XEntityResolver.hpp> +#include <com/sun/star/xml/sax/InputSource.hpp> +#include <com/sun/star/xml/sax/XDTDHandler.hpp> +#include <com/sun/star/xml/sax/XParser.hpp> +#include <com/sun/star/io/XActiveDataSource.hpp> +#include <com/sun/star/io/XActiveDataControl.hpp> +#include <com/sun/star/document/XDocumentProperties.hpp> +#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> +#include <com/sun/star/packages/zip/ZipIOException.hpp> +#include <com/sun/star/task/XStatusIndicatorFactory.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/embed/ElementModes.hpp> +#include <com/sun/star/uno/Any.h> + +#include <rtl/math.hxx> +#include <sfx2/frame.hxx> +#include <sfx2/docfile.hxx> +#include <tools/debug.hxx> +#include <tools/urlobj.hxx> +#include <svtools/sfxecode.hxx> +#include <unotools/saveopt.hxx> +#include <svl/stritem.hxx> +#include <svl/itemprop.hxx> +#include <unotools/processfactory.hxx> +#include <unotools/streamwrap.hxx> +#include <xmloff/xmlnmspe.hxx> +#include <xmloff/xmltoken.hxx> +#include <xmloff/nmspmap.hxx> +#include <xmloff/attrlist.hxx> +#include <xmloff/xmluconv.hxx> +#include <xmloff/xmlmetai.hxx> +#include <osl/mutex.hxx> +#include <comphelper/genericpropertyset.hxx> + +#include <memory> + +#include "mathmlexport.hxx" +#include "mathtype.hxx" +#include <starmath.hrc> +#include <unomodel.hxx> +#include <document.hxx> +#include <utility.hxx> + +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::document; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star; +using namespace ::xmloff::token; + +using ::rtl::OUString; +using ::rtl::OUStringBuffer; + +#define EXPORT_SVC_NAME RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.XMLExportFilter") + +#undef WANTEXCEPT + + +//////////////////////////////////////////////////////////// + +sal_Bool SmXMLExportWrapper::Export(SfxMedium &rMedium) +{ + sal_Bool bRet=sal_True; + uno::Reference<lang::XMultiServiceFactory> + xServiceFactory(utl::getProcessServiceFactory()); + DBG_ASSERT(xServiceFactory.is(),"got no service manager"); + + //Get model + uno::Reference< lang::XComponent > xModelComp(xModel, uno::UNO_QUERY ); + + sal_Bool bEmbedded = sal_False; + uno::Reference <lang::XUnoTunnel> xTunnel; + xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY); + SmModel *pModel = reinterpret_cast<SmModel *> + (xTunnel->getSomething(SmModel::getUnoTunnelId())); + + SmDocShell *pDocShell = pModel ? + static_cast<SmDocShell*>(pModel->GetObjectShell()) : 0; + if ( pDocShell && + SFX_CREATE_MODE_EMBEDDED == pDocShell->GetCreateMode() ) + bEmbedded = sal_True; + + uno::Reference<task::XStatusIndicator> xStatusIndicator; + if (!bEmbedded) + { + if (pDocShell /*&& pDocShell->GetMedium()*/) + { + DBG_ASSERT( pDocShell->GetMedium() == &rMedium, + "different SfxMedium found" ); + + SfxItemSet* pSet = rMedium.GetItemSet(); + if (pSet) + { + const SfxUnoAnyItem* pItem = static_cast<const SfxUnoAnyItem*>( + pSet->GetItem(SID_PROGRESS_STATUSBAR_CONTROL) ); + if (pItem) + pItem->GetValue() >>= xStatusIndicator; + } + } + + // set progress range and start status indicator + if (xStatusIndicator.is()) + { + sal_Int32 nProgressRange = bFlat ? 1 : 3; + xStatusIndicator->start(String(SmResId(STR_STATSTR_WRITING)), + nProgressRange); + } + } + + + // create XPropertySet with three properties for status indicator + comphelper::PropertyMapEntry aInfoMap[] = + { + { "UsePrettyPrinting", sizeof("UsePrettyPrinting")-1, 0, + &::getBooleanCppuType(), + beans::PropertyAttribute::MAYBEVOID, 0}, + { "BaseURI", sizeof("BaseURI")-1, 0, + &::getCppuType( (OUString *)0 ), + beans::PropertyAttribute::MAYBEVOID, 0 }, + { "StreamRelPath", sizeof("StreamRelPath")-1, 0, + &::getCppuType( (OUString *)0 ), + beans::PropertyAttribute::MAYBEVOID, 0 }, + { "StreamName", sizeof("StreamName")-1, 0, + &::getCppuType( (OUString *)0 ), + beans::PropertyAttribute::MAYBEVOID, 0 }, + { NULL, 0, 0, NULL, 0, 0 } + }; + uno::Reference< beans::XPropertySet > xInfoSet( + comphelper::GenericPropertySet_CreateInstance( + new comphelper::PropertySetInfo( aInfoMap ) ) ); + + SvtSaveOptions aSaveOpt; + OUString sUsePrettyPrinting(RTL_CONSTASCII_USTRINGPARAM("UsePrettyPrinting")); + sal_Bool bUsePrettyPrinting( bFlat || aSaveOpt.IsPrettyPrinting() ); + Any aAny; + aAny.setValue( &bUsePrettyPrinting, ::getBooleanCppuType() ); + xInfoSet->setPropertyValue( sUsePrettyPrinting, aAny ); + + // Set base URI + OUString sPropName( RTL_CONSTASCII_USTRINGPARAM("BaseURI") ); + xInfoSet->setPropertyValue( sPropName, makeAny( rMedium.GetBaseURL( true ) ) ); + + sal_Int32 nSteps=0; + if (xStatusIndicator.is()) + xStatusIndicator->setValue(nSteps++); + if (!bFlat) //Storage (Package) of Stream + { + uno::Reference < embed::XStorage > xStg = rMedium.GetOutputStorage(); + sal_Bool bOASIS = ( SotStorage::GetVersion( xStg ) > SOFFICE_FILEFORMAT_60 ); + + // TODO/LATER: handle the case of embedded links gracefully + if ( bEmbedded ) //&& !pStg->IsRoot() ) + { + OUString aName; + if ( rMedium.GetItemSet() ) + { + const SfxStringItem* pDocHierarchItem = static_cast<const SfxStringItem*>( + rMedium.GetItemSet()->GetItem(SID_DOC_HIERARCHICALNAME) ); + if ( pDocHierarchItem ) + aName = pDocHierarchItem->GetValue(); + } + + if ( aName.getLength() ) + { + sPropName = OUString(RTL_CONSTASCII_USTRINGPARAM("StreamRelPath")); + xInfoSet->setPropertyValue( sPropName, makeAny( aName ) ); + } + } + + if ( !bEmbedded ) + { + if (xStatusIndicator.is()) + xStatusIndicator->setValue(nSteps++); + + bRet = WriteThroughComponent( + xStg, xModelComp, "meta.xml", xServiceFactory, xInfoSet, + (bOASIS ? "com.sun.star.comp.Math.XMLOasisMetaExporter" + : "com.sun.star.comp.Math.XMLMetaExporter"), + sal_False); + } + if ( bRet ) + { + if (xStatusIndicator.is()) + xStatusIndicator->setValue(nSteps++); + + bRet = WriteThroughComponent( + xStg, xModelComp, "content.xml", xServiceFactory, xInfoSet, + "com.sun.star.comp.Math.XMLContentExporter"); + } + + if ( bRet ) + { + if (xStatusIndicator.is()) + xStatusIndicator->setValue(nSteps++); + + bRet = WriteThroughComponent( + xStg, xModelComp, "settings.xml", xServiceFactory, xInfoSet, + (bOASIS ? "com.sun.star.comp.Math.XMLOasisSettingsExporter" + : "com.sun.star.comp.Math.XMLSettingsExporter") ); + } + } + else + { + SvStream *pStream = rMedium.GetOutStream(); + uno::Reference<io::XOutputStream> xOut( + new utl::OOutputStreamWrapper(*pStream) ); + + if (xStatusIndicator.is()) + xStatusIndicator->setValue(nSteps++); + + bRet = WriteThroughComponent( + xOut, xModelComp, xServiceFactory, xInfoSet, + "com.sun.star.comp.Math.XMLContentExporter"); + } + + if (xStatusIndicator.is()) + xStatusIndicator->end(); + + return bRet; +} + + +/// export through an XML exporter component (output stream version) +sal_Bool SmXMLExportWrapper::WriteThroughComponent( + Reference<io::XOutputStream> xOutputStream, + Reference<XComponent> xComponent, + Reference<lang::XMultiServiceFactory> & rFactory, + Reference<beans::XPropertySet> & rPropSet, + const sal_Char* pComponentName ) +{ + DBG_ASSERT(xOutputStream.is(), "I really need an output stream!"); + DBG_ASSERT(xComponent.is(), "Need component!"); + DBG_ASSERT(NULL != pComponentName, "Need component name!"); + + // get component + Reference< io::XActiveDataSource > xSaxWriter( + rFactory->createInstance( + OUString::createFromAscii("com.sun.star.xml.sax.Writer") ), + UNO_QUERY ); + DBG_ASSERT( xSaxWriter.is(), "can't instantiate XML writer" ); + if (!xSaxWriter.is()) + return sal_False; + + // connect XML writer to output stream + xSaxWriter->setOutputStream( xOutputStream ); + + // prepare arguments (prepend doc handler to given arguments) + Reference<xml::sax::XDocumentHandler> xDocHandler( xSaxWriter,UNO_QUERY); + + Sequence<Any> aArgs( 2 ); + aArgs[0] <<= xDocHandler; + aArgs[1] <<= rPropSet; + + // get filter component + Reference< document::XExporter > xExporter( + rFactory->createInstanceWithArguments( + OUString::createFromAscii(pComponentName), aArgs), UNO_QUERY); + DBG_ASSERT( xExporter.is(), + "can't instantiate export filter component" ); + if ( !xExporter.is() ) + return sal_False; + + + // connect model and filter + xExporter->setSourceDocument( xComponent ); + + // filter! + Reference < XFilter > xFilter( xExporter, UNO_QUERY ); + uno::Sequence< PropertyValue > aProps(0); + xFilter->filter( aProps ); + + uno::Reference<lang::XUnoTunnel> xFilterTunnel; + xFilterTunnel = uno::Reference<lang::XUnoTunnel> + ( xFilter, uno::UNO_QUERY ); + SmXMLExport *pFilter = reinterpret_cast< SmXMLExport * >( + sal::static_int_cast< sal_uIntPtr >( + xFilterTunnel->getSomething( SmXMLExport::getUnoTunnelId() ))); + return pFilter ? pFilter->GetSuccess() : sal_True; +} + + +/// export through an XML exporter component (storage version) +sal_Bool SmXMLExportWrapper::WriteThroughComponent( + const Reference < embed::XStorage >& xStorage, + Reference<XComponent> xComponent, + const sal_Char* pStreamName, + Reference<lang::XMultiServiceFactory> & rFactory, + Reference<beans::XPropertySet> & rPropSet, + const sal_Char* pComponentName, + sal_Bool bCompress + ) +{ + DBG_ASSERT(xStorage.is(), "Need storage!"); + DBG_ASSERT(NULL != pStreamName, "Need stream name!"); + + // open stream + Reference < io::XStream > xStream; + OUString sStreamName = OUString::createFromAscii(pStreamName); + try + { + xStream = xStorage->openStreamElement( sStreamName, + embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE ); + } + catch ( uno::Exception& ) + { + DBG_ERROR( "Can't create output stream in package!" ); + return sal_False; + } + + String aPropName( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM("MediaType") ) ); + OUString aMime( RTL_CONSTASCII_USTRINGPARAM("text/xml") ); + uno::Any aAny; + aAny <<= aMime; + + uno::Reference < beans::XPropertySet > xSet( xStream, uno::UNO_QUERY ); + xSet->setPropertyValue( aPropName, aAny ); + + if ( !bCompress ) + { + aPropName = String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM("Compressed") ); + sal_Bool bFalse = sal_False; + aAny.setValue( &bFalse, ::getBooleanCppuType() ); + xSet->setPropertyValue( aPropName, aAny ); + } + + // even plain stream must be encrypted in encrypted document + OUString aTmpPropName( RTL_CONSTASCII_USTRINGPARAM("UseCommonStoragePasswordEncryption") ); + sal_Bool bTrue = sal_True; + aAny.setValue( &bTrue, ::getBooleanCppuType() ); + xSet->setPropertyValue( aTmpPropName, aAny ); + + // set Base URL + if ( rPropSet.is() ) + { + OUString sPropName( RTL_CONSTASCII_USTRINGPARAM("StreamName") ); + rPropSet->setPropertyValue( sPropName, makeAny( sStreamName ) ); + } + + // write the stuff + sal_Bool bRet = WriteThroughComponent( xStream->getOutputStream(), xComponent, rFactory, + rPropSet, pComponentName ); + + // stream is closed by SAX parser + //if ( bRet ) + // xStream->getOutputStream()->closeOutput(); + + return bRet; +} + +//////////////////////////////////////////////////////////// + +// #110680# +SmXMLExport::SmXMLExport( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory, + sal_uInt16 nExportFlags) +: SvXMLExport( xServiceFactory, MAP_INCH, XML_MATH, nExportFlags ) , + pTree(0) , + bSuccess(sal_False) +{ +} + +sal_Int64 SAL_CALL SmXMLExport::getSomething( + const uno::Sequence< sal_Int8 >& rId ) +throw(uno::RuntimeException) +{ + if ( rId.getLength() == 16 && + 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), + rId.getConstArray(), 16 ) ) + return sal::static_int_cast< sal_Int64 >(reinterpret_cast< sal_uIntPtr >(this)); + + return SvXMLExport::getSomething( rId ); +} + +const uno::Sequence< sal_Int8 > & SmXMLExport::getUnoTunnelId() throw() +{ + static uno::Sequence< sal_Int8 > * pSeq = 0; + if ( !pSeq ) + { + osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); + if ( !pSeq ) + { + static uno::Sequence< sal_Int8 > aSeq( 16 ); + rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True ); + pSeq = &aSeq; + } + } + return *pSeq; +} + +OUString SAL_CALL SmXMLExport_getImplementationName() throw() +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLExporter" ) ); +} + +uno::Sequence< OUString > SAL_CALL SmXMLExport_getSupportedServiceNames() + throw() +{ + const OUString aServiceName( EXPORT_SVC_NAME ); + const uno::Sequence< OUString > aSeq( &aServiceName, 1 ); + return aSeq; +} + +uno::Reference< uno::XInterface > SAL_CALL SmXMLExport_createInstance( + const uno::Reference< lang::XMultiServiceFactory > & rSMgr) + throw( uno::Exception ) +{ + // #110680# + // return (cppu::OWeakObject*)new SmXMLExport( EXPORT_ALL ); + // EXPORT_OASIS is required here allthough there is no differrence between + // OOo and OASIS, because without the flag, a transformation to OOo would + // be chained in. + return (cppu::OWeakObject*)new SmXMLExport( rSMgr, EXPORT_OASIS|EXPORT_ALL ); +} + +//////////////////////////////////////////////////////////// + +OUString SAL_CALL SmXMLExportMetaOOO_getImplementationName() throw() +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLMetaExporter" ) ); +} + +uno::Sequence< OUString > SAL_CALL SmXMLExportMetaOOO_getSupportedServiceNames() + throw() +{ + const OUString aServiceName( EXPORT_SVC_NAME ); + const uno::Sequence< OUString > aSeq( &aServiceName, 1 ); + return aSeq; +} + +uno::Reference< uno::XInterface > SAL_CALL SmXMLExportMetaOOO_createInstance( + const uno::Reference< lang::XMultiServiceFactory > & rSMgr) +throw( uno::Exception ) +{ + // #110680# + // return (cppu::OWeakObject*)new SmXMLExport( EXPORT_META ); + return (cppu::OWeakObject*)new SmXMLExport( rSMgr, EXPORT_META ); +} + +//////////////////////////////////////////////////////////// + +OUString SAL_CALL SmXMLExportMeta_getImplementationName() throw() +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLOasisMetaExporter" ) ); +} + +uno::Sequence< OUString > SAL_CALL SmXMLExportMeta_getSupportedServiceNames() +throw() +{ + const OUString aServiceName( EXPORT_SVC_NAME ); + const uno::Sequence< OUString > aSeq( &aServiceName, 1 ); + return aSeq; +} + +uno::Reference< uno::XInterface > SAL_CALL SmXMLExportMeta_createInstance( + const uno::Reference< lang::XMultiServiceFactory > & rSMgr) +throw( uno::Exception ) +{ + // #110680# + // return (cppu::OWeakObject*)new SmXMLExport( EXPORT_META ); + return (cppu::OWeakObject*)new SmXMLExport( rSMgr, EXPORT_OASIS|EXPORT_META ); +} + +//////////////////////////////////////////////////////////// + +OUString SAL_CALL SmXMLExportSettingsOOO_getImplementationName() throw() +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLSettingsExporter" ) ); +} + +uno::Sequence< OUString > SAL_CALL SmXMLExportSettingsOOO_getSupportedServiceNames() +throw() +{ + const OUString aServiceName( EXPORT_SVC_NAME ); + const uno::Sequence< OUString > aSeq( &aServiceName, 1 ); + return aSeq; +} + +uno::Reference< uno::XInterface > SAL_CALL SmXMLExportSettingsOOO_createInstance( + const uno::Reference< lang::XMultiServiceFactory > & rSMgr) +throw( uno::Exception ) +{ + // #110680# + // return (cppu::OWeakObject*)new SmXMLExport( EXPORT_SETTINGS ); + return (cppu::OWeakObject*)new SmXMLExport( rSMgr, EXPORT_SETTINGS ); +} + +//////////////////////////////////////////////////////////// + +OUString SAL_CALL SmXMLExportSettings_getImplementationName() throw() +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLOasisSettingsExporter" ) ); +} + +uno::Sequence< OUString > SAL_CALL SmXMLExportSettings_getSupportedServiceNames() +throw() +{ + const OUString aServiceName( EXPORT_SVC_NAME ); + const uno::Sequence< OUString > aSeq( &aServiceName, 1 ); + return aSeq; +} + +uno::Reference< uno::XInterface > SAL_CALL SmXMLExportSettings_createInstance( + const uno::Reference< lang::XMultiServiceFactory > & rSMgr) +throw( uno::Exception ) +{ + // #110680# + // return (cppu::OWeakObject*)new SmXMLExport( EXPORT_SETTINGS ); + return (cppu::OWeakObject*)new SmXMLExport( rSMgr, EXPORT_OASIS|EXPORT_SETTINGS ); +} + +//////////////////////////////////////////////////////////// + +OUString SAL_CALL SmXMLExportContent_getImplementationName() throw() +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLContentExporter" ) ); +} + +uno::Sequence< OUString > SAL_CALL SmXMLExportContent_getSupportedServiceNames() + throw() +{ + const OUString aServiceName( EXPORT_SVC_NAME ); + const uno::Sequence< OUString > aSeq( &aServiceName, 1 ); + return aSeq; +} + +uno::Reference< uno::XInterface > SAL_CALL SmXMLExportContent_createInstance( + const uno::Reference< lang::XMultiServiceFactory > & rSMgr) +throw( uno::Exception ) +{ + // #110680# + // return (cppu::OWeakObject*)new SmXMLExport( EXPORT_CONTENT ); + // The EXPORT_OASIS flag is only required to avoid that a transformer is + // chanied in + return (cppu::OWeakObject*)new SmXMLExport( rSMgr, EXPORT_OASIS|EXPORT_CONTENT ); +} + +//////////////////////////////////////////////////////////// + +// XServiceInfo +// override empty method from parent class +rtl::OUString SAL_CALL SmXMLExport::getImplementationName() +throw(uno::RuntimeException) +{ + OUString aTxt; + switch( getExportFlags() ) + { + case EXPORT_META: + aTxt = SmXMLExportMeta_getImplementationName(); + break; + case EXPORT_SETTINGS: + aTxt = SmXMLExportSettings_getImplementationName(); + break; + case EXPORT_CONTENT: + aTxt = SmXMLExportContent_getImplementationName(); + break; + case EXPORT_ALL: + default: + aTxt = SmXMLExport_getImplementationName(); + break; + } + return aTxt; +} + +sal_uInt32 SmXMLExport::exportDoc(enum XMLTokenEnum eClass) +{ + if ( (getExportFlags() & EXPORT_CONTENT) == 0 ) + { + SvXMLExport::exportDoc( eClass ); + } + else + { + uno::Reference <frame::XModel> xModel = GetModel(); + uno::Reference <lang::XUnoTunnel> xTunnel; + xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY); + SmModel *pModel = reinterpret_cast<SmModel *> + (xTunnel->getSomething(SmModel::getUnoTunnelId())); + + if (pModel) + { + SmDocShell *pDocShell = + static_cast<SmDocShell*>(pModel->GetObjectShell()); + pTree = pDocShell->GetFormulaTree(); + aText = pDocShell->GetText(); + } + + GetDocHandler()->startDocument(); + + /*Add xmlns line*/ + SvXMLAttributeList &rList = GetAttrList(); + + // make use of a default namespace + ResetNamespaceMap(); // Math doesn't need namespaces from xmloff, since it now uses default namespaces (because that is common with current MathML usage in the web) + _GetNamespaceMap().Add( OUString::createFromAscii(""), GetXMLToken(XML_N_MATH), XML_NAMESPACE_MATH ); + + rList.AddAttribute(GetNamespaceMap().GetAttrNameByKey(XML_NAMESPACE_MATH_IDX), + GetNamespaceMap().GetNameByKey( XML_NAMESPACE_MATH_IDX)); + + //I think we need something like ImplExportEntities(); + _ExportContent(); + GetDocHandler()->endDocument(); + } + + bSuccess=sal_True; + return 0; +} + +void SmXMLExport::_ExportContent() +{ + SvXMLElementExport aEquation(*this, XML_NAMESPACE_MATH, XML_MATH, sal_True, sal_True); + SvXMLElementExport *pSemantics=0; + + if (aText.Len()) + { + pSemantics = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, + XML_SEMANTICS, sal_True, sal_True); + } + + ExportNodes(pTree, 0); + + if (aText.Len()) + { + // Convert symbol names + uno::Reference <frame::XModel> xModel = GetModel(); + uno::Reference <lang::XUnoTunnel> xTunnel; + xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY); + SmModel *pModel = reinterpret_cast<SmModel *> + (xTunnel->getSomething(SmModel::getUnoTunnelId())); + SmDocShell *pDocShell = pModel ? + static_cast<SmDocShell*>(pModel->GetObjectShell()) : 0; + DBG_ASSERT( pDocShell, "doc shell missing" ); + if (pDocShell) + { + SmParser &rParser = pDocShell->GetParser(); + BOOL bVal = rParser.IsExportSymbolNames(); + rParser.SetExportSymbolNames( TRUE ); + SmNode *pTmpTree = rParser.Parse( aText ); + aText = rParser.GetText(); + delete pTmpTree; + rParser.SetExportSymbolNames( bVal ); + } + + AddAttribute(XML_NAMESPACE_MATH, XML_ENCODING, + OUString(RTL_CONSTASCII_USTRINGPARAM("StarMath 5.0"))); + SvXMLElementExport aAnnotation(*this, XML_NAMESPACE_MATH, + XML_ANNOTATION, sal_True, sal_False); + GetDocHandler()->characters(OUString( aText )); + } + delete pSemantics; +} + +void SmXMLExport::GetViewSettings( Sequence < PropertyValue >& aProps) +{ + uno::Reference <frame::XModel> xModel = GetModel(); + if ( !xModel.is() ) + return; + + uno::Reference <lang::XUnoTunnel> xTunnel; + xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY); + SmModel *pModel = reinterpret_cast<SmModel *> + (xTunnel->getSomething(SmModel::getUnoTunnelId())); + + if ( !pModel ) + return; + + SmDocShell *pDocShell = + static_cast<SmDocShell*>(pModel->GetObjectShell()); + if ( !pDocShell ) + return; + + aProps.realloc( 4 ); + PropertyValue *pValue = aProps.getArray(); + sal_Int32 nIndex = 0; + + Rectangle aRect( pDocShell->GetVisArea() ); + + pValue[nIndex].Name = OUString( RTL_CONSTASCII_USTRINGPARAM ( "ViewAreaTop") ); + pValue[nIndex++].Value <<= aRect.Top(); + + pValue[nIndex].Name = OUString( RTL_CONSTASCII_USTRINGPARAM ( "ViewAreaLeft") ); + pValue[nIndex++].Value <<= aRect.Left(); + + pValue[nIndex].Name = OUString( RTL_CONSTASCII_USTRINGPARAM ( "ViewAreaWidth") ); + pValue[nIndex++].Value <<= aRect.GetWidth(); + + pValue[nIndex].Name = OUString( RTL_CONSTASCII_USTRINGPARAM ( "ViewAreaHeight") ); + pValue[nIndex++].Value <<= aRect.GetHeight(); +} + +void SmXMLExport::GetConfigurationSettings( Sequence < PropertyValue > & rProps) +{ + Reference < XPropertySet > xProps ( GetModel(), UNO_QUERY ); + if ( xProps.is() ) + { + Reference< XPropertySetInfo > xPropertySetInfo = xProps->getPropertySetInfo(); + if (xPropertySetInfo.is()) + { + Sequence< Property > aProps = xPropertySetInfo->getProperties(); + sal_Int32 nCount(aProps.getLength()); + if (nCount > 0) + { + rProps.realloc(nCount); + PropertyValue* pProps = rProps.getArray(); + if (pProps) + { + const OUString sFormula ( RTL_CONSTASCII_USTRINGPARAM ( "Formula" ) ); + const OUString sBasicLibraries ( RTL_CONSTASCII_USTRINGPARAM ( "BasicLibraries" ) ); + const OUString sDialogLibraries ( RTL_CONSTASCII_USTRINGPARAM ( "DialogLibraries" ) ); + const OUString sRuntimeUID ( RTL_CONSTASCII_USTRINGPARAM ( "RuntimeUID" ) ); + for (sal_Int32 i = 0; i < nCount; i++, pProps++) + { + const OUString &rPropName = aProps[i].Name; + if (rPropName != sFormula && + rPropName != sBasicLibraries && + rPropName != sDialogLibraries && + rPropName != sRuntimeUID) + { + pProps->Name = rPropName; + pProps->Value = xProps->getPropertyValue(rPropName); + } + } + } + } + } + } +} + +void SmXMLExport::ExportLine(const SmNode *pNode, int nLevel) +{ + ExportExpression(pNode, nLevel); +} + +void SmXMLExport::ExportBinaryHorizontal(const SmNode *pNode, int nLevel) +{ + ExportExpression(pNode, nLevel); +} + +void SmXMLExport::ExportUnaryHorizontal(const SmNode *pNode, int nLevel) +{ + ExportExpression(pNode, nLevel); +} + +void SmXMLExport::ExportExpression(const SmNode *pNode, int nLevel) +{ + SvXMLElementExport *pRow=0; + ULONG nSize = pNode->GetNumSubNodes(); + + if (nSize > 1) + pRow = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MROW, sal_True, sal_True); + + //if (nSize) + //{ + for (USHORT i = 0; i < nSize; i++) + if (const SmNode *pTemp = pNode->GetSubNode(i)) + ExportNodes(pTemp, nLevel+1); + //} +#if 0 + else + { + //This saves us from situations like "a newline" where the + //lack of a term following the newline would otherwise create + //a incorrect token like <mtr/> + SvXMLElementExport aDummy(*this, XML_NAMESPACE_MATH, XML_MI, sal_True, sal_False); + sal_Unicode nArse[2] = {'\n','\0'}; + GetDocHandler()->characters(nArse); + } +#endif + + delete pRow; +} + +void SmXMLExport::ExportBinaryVertical(const SmNode *pNode, int nLevel) +{ + DBG_ASSERT(pNode->GetNumSubNodes()==3,"Bad Fraction"); + SvXMLElementExport aFraction(*this, XML_NAMESPACE_MATH, XML_MFRAC, sal_True, sal_True); + ExportNodes(pNode->GetSubNode(0), nLevel); + ExportNodes(pNode->GetSubNode(2), nLevel); +} + +void SmXMLExport::ExportTable(const SmNode *pNode, int nLevel) +{ + SvXMLElementExport *pTable=0; + + USHORT nSize = pNode->GetNumSubNodes(); + + //If the list ends in newline then the last entry has + //no subnodes, the newline is superfulous so we just drop + //the last node, inclusion would create a bad MathML + //table + if (nSize >= 1 && pNode->GetSubNode(nSize-1)->GetNumSubNodes() == 0) + --nSize; + + // try to avoid creating a mtable element when the formula consists only + // of a single output line + if (nLevel || (nSize >1)) + pTable = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MTABLE, sal_True, sal_True); + + for (USHORT i = 0; i < nSize; i++) + if (const SmNode *pTemp = pNode->GetSubNode(i)) + { + SvXMLElementExport *pRow=0; + SvXMLElementExport *pCell=0; + if (pTable) + { + pRow = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MTR, sal_True, sal_True); + pCell = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MTD, sal_True, sal_True); + } + ExportNodes(pTemp, nLevel+1); + delete pCell; + delete pRow; + } + + delete pTable; +} + +void SmXMLExport::ExportMath(const SmNode *pNode, int /*nLevel*/) +{ + const SmMathSymbolNode *pTemp = static_cast<const SmMathSymbolNode *>(pNode); + SvXMLElementExport aMath(*this, XML_NAMESPACE_MATH, XML_MO, sal_True, sal_False); + sal_Unicode nArse[2]; + nArse[0] = pTemp->GetText().GetChar(0); + sal_Unicode cTmp = ConvertMathToMathML( nArse[0] ); + if (cTmp != 0) + nArse[0] = cTmp; + DBG_ASSERT(nArse[0] != 0xffff,"Non existant symbol"); + nArse[1] = 0; + GetDocHandler()->characters(nArse); +} + +void SmXMLExport::ExportText(const SmNode *pNode, int /*nLevel*/) +{ + SvXMLElementExport *pText; + const SmTextNode *pTemp = static_cast<const SmTextNode *>(pNode); + switch (pNode->GetToken().eType) + { + default: + case TIDENT: + { + //Note that we change the fontstyle to italic for strings that + //are italic and longer than a single character. + sal_Bool bIsItalic = IsItalic( pTemp->GetFont() ); + if ((pTemp->GetText().Len() > 1) && bIsItalic) + AddAttribute(XML_NAMESPACE_MATH, XML_MATHVARIANT, XML_ITALIC); + else if ((pTemp->GetText().Len() == 1) && !bIsItalic) + AddAttribute(XML_NAMESPACE_MATH, XML_MATHVARIANT, XML_NORMAL); + pText = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MI,sal_True,sal_False); + break; + } + case TNUMBER: + pText = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MN,sal_True,sal_False); + break; + case TTEXT: + pText = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MTEXT,sal_True,sal_False); + break; + } + GetDocHandler()->characters(OUString(pTemp->GetText().GetBuffer())); + delete pText; +} + +void SmXMLExport::ExportBlank(const SmNode * /*pNode*/, int /*nLevel*/) +{ + //!! exports an empty <mi> tag since for example "~_~" is allowed in + //!! Math (so it has no sense at all) but must not result in an empty + //!! <msub> tag in MathML !! + + SvXMLElementExport *pText; + //const SmBlankNode *pTemp = static_cast<const SmBlankNode *>(pNode); + + pText = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MI, sal_True, sal_False); + + GetDocHandler()->characters( OUString() ); + delete pText; +} + +void SmXMLExport::ExportSubSupScript(const SmNode *pNode, int nLevel) +{ + const SmNode *pSub = 0; + const SmNode *pSup = 0; + const SmNode *pCSub = 0; + const SmNode *pCSup = 0; + const SmNode *pLSub = 0; + const SmNode *pLSup = 0; + SvXMLElementExport *pThing = 0, *pThing2 = 0; + + //if we have prescripts at all then we must use the tensor notation + + //This is one of those excellent locations where scope is vital to + //arrange the construction and destruction of the element helper + //classes correctly + pLSub = pNode->GetSubNode(LSUB+1); + pLSup = pNode->GetSubNode(LSUP+1); + if (pLSub || pLSup) + { + SvXMLElementExport aMultiScripts(*this, XML_NAMESPACE_MATH, + XML_MMULTISCRIPTS, sal_True, sal_True); + + + if (NULL != (pCSub = pNode->GetSubNode(CSUB+1)) + && NULL != (pCSup = pNode->GetSubNode(CSUP+1))) + { + pThing2 = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, + XML_MUNDEROVER, sal_True,sal_True); + } + else if (NULL != (pCSub = pNode->GetSubNode(CSUB+1))) + { + pThing2 = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, + XML_MUNDER, sal_True,sal_True); + } + else if (NULL != (pCSup = pNode->GetSubNode(CSUP+1))) + { + pThing2 = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, + XML_MOVER, sal_True,sal_True); + } + + ExportNodes(pNode->GetSubNode(0), nLevel+1); //Main Term + + if (pCSub) + ExportNodes(pCSub, nLevel+1); + if (pCSup) + ExportNodes(pCSup, nLevel+1); + delete pThing2; + + pSub = pNode->GetSubNode(RSUB+1); + pSup = pNode->GetSubNode(RSUP+1); + if (pSub || pSup) + { + if (pSub) + ExportNodes(pSub, nLevel+1); + else + { + SvXMLElementExport aNone(*this, XML_NAMESPACE_MATH, XML_NONE,sal_True,sal_True); + } + if (pSup) + ExportNodes(pSup, nLevel+1); + else + { + SvXMLElementExport aNone(*this, XML_NAMESPACE_MATH, XML_NONE,sal_True,sal_True); + } + } + + //Seperator element between suffix and prefix sub/sup pairs + { + SvXMLElementExport aPrescripts(*this, XML_NAMESPACE_MATH, + XML_MPRESCRIPTS, sal_True,sal_True); + } + + if (pLSub) + ExportNodes(pLSub, nLevel+1); + else + { + SvXMLElementExport aNone(*this, XML_NAMESPACE_MATH, XML_NONE, + sal_True,sal_True); + + } + if (pLSup) + ExportNodes(pLSup, nLevel+1); + else + { + SvXMLElementExport aNone(*this, XML_NAMESPACE_MATH, XML_NONE, + sal_True,sal_True); + + } + } + else + { + if (NULL != (pSub = pNode->GetSubNode(RSUB+1)) && + NULL != (pSup = pNode->GetSubNode(RSUP+1))) + { + pThing = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, + XML_MSUBSUP, sal_True,sal_True); + } + else if (NULL != (pSub = pNode->GetSubNode(RSUB+1))) + { + pThing = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MSUB, + sal_True,sal_True); + } + else if (NULL != (pSup = pNode->GetSubNode(RSUP+1))) + { + pThing = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MSUP, + sal_True,sal_True); + } + + if (NULL != (pCSub = pNode->GetSubNode(CSUB+1)) + && NULL != (pCSup=pNode->GetSubNode(CSUP+1))) + { + pThing2 = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, + XML_MUNDEROVER, sal_True,sal_True); + } + else if (NULL != (pCSub = pNode->GetSubNode(CSUB+1))) + { + pThing2 = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, + XML_MUNDER, sal_True,sal_True); + } + else if (NULL != (pCSup = pNode->GetSubNode(CSUP+1))) + { + pThing2 = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, + XML_MOVER, sal_True,sal_True); + } + ExportNodes(pNode->GetSubNode(0), nLevel+1); //Main Term + + if (pCSub) + ExportNodes(pCSub, nLevel+1); + if (pCSup) + ExportNodes(pCSup, nLevel+1); + delete pThing2; + + if (pSub) + ExportNodes(pSub, nLevel+1); + if (pSup) + ExportNodes(pSup, nLevel+1); + delete pThing; + } +} + +void SmXMLExport::ExportBrace(const SmNode *pNode, int nLevel) +{ + const SmNode *pTemp; + const SmNode *pLeft=pNode->GetSubNode(0); + const SmNode *pRight=pNode->GetSubNode(2); + SvXMLElementExport *pFences=0,*pRow=0; + if ( ((pLeft) && (pLeft->GetToken().eType != TNONE)) && + ((pRight) && (pRight->GetToken().eType != TNONE)) && + (pNode->GetScaleMode() == SCALE_HEIGHT)) + { + sal_Unicode nArse[2]; + nArse[1] = 0; + nArse[0] = static_cast< + const SmMathSymbolNode* >(pLeft)->GetText().GetChar(0); + DBG_ASSERT(nArse[0] != 0xffff,"Non existant symbol"); + AddAttribute(XML_NAMESPACE_MATH, XML_OPEN,nArse); + nArse[0] = static_cast< + const SmMathSymbolNode* >(pRight)->GetText().GetChar(0); + DBG_ASSERT(nArse[0] != 0xffff,"Non existant symbol"); + AddAttribute(XML_NAMESPACE_MATH, XML_CLOSE,nArse); + pFences = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MFENCED, + sal_True,sal_True); + } + else if (pLeft && (pLeft->GetToken().eType != TNONE)) + { + pRow = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MROW, + sal_True, sal_True); + if (pNode->GetScaleMode() == SCALE_HEIGHT) + AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_TRUE); + else + AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_FALSE); + ExportNodes(pLeft, nLevel+1); + } + else + pRow = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MROW, + sal_True, sal_True); + + if (NULL != (pTemp = pNode->GetSubNode(1))) + ExportNodes(pTemp, nLevel+1); + if (pFences) + delete pFences; + else if (pRight && (pRight->GetToken().eType != TNONE)) + { + if (pNode->GetScaleMode() == SCALE_HEIGHT) + AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_TRUE); + else + AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_FALSE); + ExportNodes(pRight, nLevel+1); + } + delete pRow; +} + +void SmXMLExport::ExportRoot(const SmNode *pNode, int nLevel) +{ + if (pNode->GetSubNode(0)) + { + SvXMLElementExport aRoot(*this, XML_NAMESPACE_MATH, XML_MROOT,sal_True, + sal_True); + ExportNodes(pNode->GetSubNode(2), nLevel+1); + ExportNodes(pNode->GetSubNode(0), nLevel+1); + } + else + { + SvXMLElementExport aSqrt(*this, XML_NAMESPACE_MATH, XML_MSQRT,sal_True, + sal_True); + ExportNodes(pNode->GetSubNode(2), nLevel+1); + } +} + +void SmXMLExport::ExportOperator(const SmNode *pNode, int nLevel) +{ + /*we need to either use content or font and size attributes + *here*/ +#if 0 + { + SvXMLElementExport aMath(*this, XML_NAMESPACE_MATH, XML_MO, + sal_True,sal_False); + SmTextNode *pTemp = (SmTextNode *)pNode->GetSubNode(0); + GetDocHandler()->characters(pTemp->GetText()); + } +#endif + SvXMLElementExport aRow(*this, XML_NAMESPACE_MATH, XML_MROW, + sal_True, sal_True); + ExportNodes(pNode->GetSubNode(0), nLevel+1); + ExportNodes(pNode->GetSubNode(1), nLevel+1); +} + +void SmXMLExport::ExportAttributes(const SmNode *pNode, int nLevel) +{ + SvXMLElementExport *pElement=0; + + if (pNode->GetToken().eType == TUNDERLINE) + { + AddAttribute(XML_NAMESPACE_MATH, XML_ACCENTUNDER, + XML_TRUE); + pElement = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MUNDER, + sal_True,sal_True); + } + else if (pNode->GetToken().eType != TOVERSTRIKE) + { + AddAttribute(XML_NAMESPACE_MATH, XML_ACCENT, + XML_TRUE); + pElement = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MOVER, + sal_True,sal_True); + } + + ExportNodes(pNode->GetSubNode(1), nLevel+1); + switch (pNode->GetToken().eType) + { + case TOVERLINE: + { + //proper entity support required + SvXMLElementExport aMath(*this, XML_NAMESPACE_MATH, XML_MO, + sal_True,sal_True); +#if 0 + GetDocHandler()->characters( + OUString(RTL_CONSTASCII_USTRINGPARAM("&overbar;"))); +#else + sal_Unicode nArse[2] = {0xAF,0x00}; +#endif + GetDocHandler()->characters(nArse); + } + break; + case TUNDERLINE: + { + //proper entity support required + SvXMLElementExport aMath(*this, XML_NAMESPACE_MATH, XML_MO, + sal_True,sal_True); +#if 0 + GetDocHandler()->characters( + OUString(RTL_CONSTASCII_USTRINGPARAM("&underbar;"))); +#else + sal_Unicode nArse[2] = {0x0332,0x00}; +#endif + GetDocHandler()->characters(nArse); + } + break; + case TOVERSTRIKE: + break; + default: + ExportNodes(pNode->GetSubNode(0), nLevel+1); + break; + } + delete pElement; +} + +static bool lcl_HasEffectOnMathvariant( const SmTokenType eType ) +{ + return eType == TBOLD || eType == TNBOLD || + eType == TITALIC || eType == TNBOLD || + eType == TSANS || eType == TSERIF || eType == TFIXED; +} + +void SmXMLExport::ExportFont(const SmNode *pNode, int nLevel) +{ + SvXMLElementExport *pElement = 0; + + // + // gather the mathvariant attribut relevant data from all + // successively following SmFontNodes... + // + int nBold = -1; // for the following variables: -1 = yet undefined; 0 = false; 1 = true; + int nItalic = -1; // for the following variables: -1 = yet undefined; 0 = false; 1 = true; + int nSansSerifFixed = -1; + SmTokenType eNodeType = TUNKNOWN; + while (lcl_HasEffectOnMathvariant( (eNodeType = pNode->GetToken().eType) )) + { + switch (eNodeType) + { + case TBOLD : nBold = 1; break; + case TNBOLD : nBold = 0; break; + case TITALIC : nItalic = 1; break; + case TNITALIC : nItalic = 0; break; + case TSANS : nSansSerifFixed = 0; break; + case TSERIF : nSansSerifFixed = 1; break; + case TFIXED : nSansSerifFixed = 2; break; + default: + DBG_ASSERT( 0, "unexpected case" ); + } + // According to the parser every node that is to be evaluated heres + // has a single non-zero subnode at index 1!! Thus we only need to check + // that single node for follow-up nodes that have an effect on the attribute. + if (pNode->GetNumSubNodes() > 1 && pNode->GetSubNode(1) && + lcl_HasEffectOnMathvariant( pNode->GetSubNode(1)->GetToken().eType)) + { + pNode = pNode->GetSubNode(1); + } + else + break; + } + + switch (pNode->GetToken().eType) + { + //wrap a phantom element around everything*/ + case TPHANTOM: + pElement = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, + XML_MPHANTOM, sal_True,sal_True); + break; + case TBLACK: + AddAttribute(XML_NAMESPACE_MATH, XML_COLOR, XML_BLACK); + break; + case TWHITE: + AddAttribute(XML_NAMESPACE_MATH, XML_COLOR, XML_WHITE); + break; + case TRED: + AddAttribute(XML_NAMESPACE_MATH, XML_COLOR, XML_RED); + break; + case TGREEN: + AddAttribute(XML_NAMESPACE_MATH, XML_COLOR, XML_GREEN); + break; + case TBLUE: + AddAttribute(XML_NAMESPACE_MATH, XML_COLOR, XML_BLUE); + break; + case TCYAN: + AddAttribute(XML_NAMESPACE_MATH, XML_COLOR, XML_AQUA); + break; + case TMAGENTA: + AddAttribute(XML_NAMESPACE_MATH, XML_COLOR, XML_FUCHSIA); + break; + case TYELLOW: + AddAttribute(XML_NAMESPACE_MATH, XML_COLOR, XML_YELLOW); + break; + case TSIZE: + { + const SmFontNode *pFontNode = static_cast<const SmFontNode *>(pNode); + const Fraction &aFrac = pFontNode->GetSizeParameter(); + + OUStringBuffer sStrBuf; + switch(pFontNode->GetSizeType()) + { + case FNTSIZ_MULTIPLY: + SvXMLUnitConverter::convertDouble(sStrBuf, + static_cast<double>(aFrac*Fraction(100.00))); + sStrBuf.append(static_cast<sal_Unicode>('%')); + break; + case FNTSIZ_DIVIDE: + SvXMLUnitConverter::convertDouble(sStrBuf, + static_cast<double>(Fraction(100.00)/aFrac)); + sStrBuf.append(static_cast<sal_Unicode>('%')); + break; + case FNTSIZ_ABSOLUT: + SvXMLUnitConverter::convertDouble(sStrBuf, + static_cast<double>(aFrac)); + sStrBuf.append( + GetXMLToken(XML_UNIT_PT)); + break; + default: + { + //The problem here is that the wheels fall off because + //font size is stored in 100th's of a mm not pts, and + //rounding errors take their toll on the original + //value specified in points. + + //Must fix StarMath to retain the original pt values + Fraction aTemp = Sm100th_mmToPts(pFontNode->GetFont(). + GetSize().Height()); + + if (pFontNode->GetSizeType() == FNTSIZ_MINUS) + aTemp-=aFrac; + else + aTemp+=aFrac; + + double mytest = static_cast<double>(aTemp); + + mytest = ::rtl::math::round(mytest,1); + SvXMLUnitConverter::convertDouble(sStrBuf,mytest); + sStrBuf.append(GetXMLToken(XML_UNIT_PT)); + } + break; + } + + OUString sStr(sStrBuf.makeStringAndClear()); + AddAttribute(XML_NAMESPACE_MATH, XML_MATHSIZE, sStr); + } + break; + case TBOLD: + case TITALIC: + case TNBOLD: + case TNITALIC: + case TFIXED: + case TSANS: + case TSERIF: + { + // nBold: -1 = yet undefined; 0 = false; 1 = true; + // nItalic: -1 = yet undefined; 0 = false; 1 = true; + // nSansSerifFixed: -1 = undefined; 0 = sans; 1 = serif; 2 = fixed; + const sal_Char *pText = "normal"; + if (nSansSerifFixed == -1 || nSansSerifFixed == 1) + { + pText = "normal"; + if (nBold == 1 && nItalic != 1) + pText = "bold"; + else if (nBold != 1 && nItalic == 1) + pText = "italic"; + else if (nBold == 1 && nItalic == 1) + pText = "bold-italic"; + } + else if (nSansSerifFixed == 0) + { + pText = "sans-serif"; + if (nBold == 1 && nItalic != 1) + pText = "bold-sans-serif"; + else if (nBold != 1 && nItalic == 1) + pText = "sans-serif-italic"; + else if (nBold == 1 && nItalic == 1) + pText = "sans-serif-bold-italic"; + } + else if (nSansSerifFixed == 2) + pText = "monospace"; // no modifiers allowed for monospace ... + else + { + DBG_ASSERT( 0, "unexpected case" ); + } + AddAttribute(XML_NAMESPACE_MATH, XML_MATHVARIANT, A2OU(pText)); + } + break; + default: + break; + + } +#if 0 + if (pNode->GetNumSubNodes() > 1) //or in the future is a node that + //cannot take the currently supported + //properties +#endif + //for now we will just always export with a style and not worry about + //anyone else for the moment. + { + //wrap a style around it + SvXMLElementExport aStyle(*this, XML_NAMESPACE_MATH, XML_MSTYLE, sal_True,sal_True); + ExportExpression(pNode, nLevel); + } +#if 0 + else + ExportNodes(pNode->GetSubNode(0), nLevel+1); +#endif + + delete pElement; +} + + +void SmXMLExport::ExportVerticalBrace(const SmNode *pNode, int nLevel) +{ + //Place the overbrace value OVER a vertical brace and then place that + //expression OVER the overbrace value, If someone can find a + //dedicated term in MathML to handle this overbrace/underbrace concept + //let me know. C. + XMLTokenEnum which; + + switch (pNode->GetToken().eType) + { + case TOVERBRACE: + default: + which = XML_MOVER; + break; + case TUNDERBRACE: + which = XML_MUNDER; + break; + } + + DBG_ASSERT(pNode->GetNumSubNodes()==3,"Bad Vertical Brace"); + SvXMLElementExport aOver1(*this, XML_NAMESPACE_MATH,which, sal_True, sal_True); + {//Scoping + // using accents will draw the over-/underbraces too close to the base + // see http://www.w3.org/TR/MathML2/chapter3.html#id.3.4.5.2 + // also XML_ACCENT is illegal with XML_MUNDER. Thus no XML_ACCENT attribut here! +// AddAttribute(XML_NAMESPACE_MATH, XML_ACCENT, XML_TRUE); + SvXMLElementExport aOver2(*this, XML_NAMESPACE_MATH,which, sal_True, sal_True); + ExportNodes(pNode->GetSubNode(0), nLevel); + ExportNodes(pNode->GetSubNode(1), nLevel); + } + ExportNodes(pNode->GetSubNode(2), nLevel); +} + +void SmXMLExport::ExportMatrix(const SmNode *pNode, int nLevel) +{ + SvXMLElementExport aTable(*this, XML_NAMESPACE_MATH, XML_MTABLE, sal_True, sal_True); + const SmMatrixNode *pMatrix = static_cast<const SmMatrixNode *>(pNode); + USHORT i=0; + for (ULONG y = 0; y < pMatrix->GetNumRows(); y++) + { + SvXMLElementExport aRow(*this, XML_NAMESPACE_MATH, XML_MTR, sal_True, sal_True); + for (ULONG x = 0; x < pMatrix->GetNumCols(); x++) + if (const SmNode *pTemp = pNode->GetSubNode(i++)) + { + SvXMLElementExport aCell(*this, XML_NAMESPACE_MATH, XML_MTD, sal_True, sal_True); + ExportNodes(pTemp, nLevel+1); + } + } +} + +void SmXMLExport::ExportNodes(const SmNode *pNode, int nLevel) +{ + if (!pNode) + return; + switch(pNode->GetType()) + { + case NTABLE: + ExportTable(pNode, nLevel); + break; + case NALIGN: + case NBRACEBODY: + case NEXPRESSION: + ExportExpression(pNode, nLevel); + break; + case NLINE: + ExportLine(pNode, nLevel); + break; + case NTEXT: + ExportText(pNode, nLevel); + break; + case NSPECIAL: //NSPECIAL requires some sort of Entity preservation in the XML engine. + case NGLYPH_SPECIAL: + case NMATH: + { + sal_Unicode cTmp = 0; + const SmTextNode *pTemp = static_cast< const SmTextNode * >(pNode); + if (pTemp->GetText().Len() > 0) + cTmp = ConvertMathToMathML( pTemp->GetText().GetChar(0) ); + if (cTmp == 0) + { + // no conversion to MathML implemented -> export it as text + // thus at least it will not vanish into nothing + ExportText(pNode, nLevel); + } + else + { + //To fully handle generic MathML we need to implement the full + //operator dictionary, we will generate MathML with explicit + //stretchiness for now. + sal_Int16 nLength = GetAttrList().getLength(); + sal_Bool bAddStretch=sal_True; + for ( sal_Int16 i = 0; i < nLength; i++ ) + { + OUString sLocalName; + sal_uInt16 nPrefix = GetNamespaceMap().GetKeyByAttrName( + GetAttrList().getNameByIndex(i), &sLocalName ); + + if ( ( XML_NAMESPACE_MATH == nPrefix ) && + IsXMLToken(sLocalName, XML_STRETCHY) ) + { + bAddStretch = sal_False; + break; + } + } + if (bAddStretch) + { + AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_FALSE); + } + ExportMath(pNode, nLevel); + } + } + break; + case NPLACE: + ExportMath(pNode, nLevel); + break; + case NBINHOR: + ExportBinaryHorizontal(pNode, nLevel); + break; + case NUNHOR: + ExportUnaryHorizontal(pNode, nLevel); + break; + case NBRACE: + ExportBrace(pNode, nLevel); + break; + case NBINVER: + ExportBinaryVertical(pNode, nLevel); + break; + case NSUBSUP: + ExportSubSupScript(pNode, nLevel); + break; + case NROOT: + ExportRoot(pNode, nLevel); + break; + case NOPER: + ExportOperator(pNode, nLevel); + break; + case NATTRIBUT: + ExportAttributes(pNode, nLevel); + break; + case NFONT: + ExportFont(pNode, nLevel); + break; + case NVERTICAL_BRACE: + ExportVerticalBrace(pNode, nLevel); + break; + case NMATRIX: + ExportMatrix(pNode, nLevel); + break; + case NBLANK: + ExportBlank(pNode, nLevel); + break; + default: + DBG_ASSERT( 0, "Warning: failed to export a node?" ); + break; + +#if 0 + default: + { + ULONG nSize = pNode->GetNumSubNodes(); + for (ULONG i = 0; i < nSize; i++) + if (SmNode *pTemp = pNode->GetSubNode(i)) + ExportNodes(pTemp, nLevel+1); + } + break; +#endif + } +} + +//////////////////////////////////////////////////////////// + diff --git a/starmath/source/mathmlexport.hxx b/starmath/source/mathmlexport.hxx index fa76076e6616..361d97e054b0 100644 --- a/starmath/source/mathmlexport.hxx +++ b/starmath/source/mathmlexport.hxx @@ -1,146 +1,143 @@ -/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: x $
- * $Revision: 1.00 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef _MATHMLEXPORT_HXX_
-#define _MATHMLEXPORT_HXX_
-
-#include <xmloff/xmlimp.hxx>
-#include <xmloff/xmlexp.hxx>
-#include <xmloff/DocumentSettingsContext.hxx>
-#include <xmloff/xmltoken.hxx>
-
-#include <node.hxx>
-
-class SfxMedium;
-namespace com { namespace sun { namespace star {
- namespace io {
- class XInputStream;
- class XOutputStream; }
- namespace beans {
- class XPropertySet; }
-} } }
-
-
-////////////////////////////////////////////////////////////
-
-class SmXMLExportWrapper
-{
- com::sun::star::uno::Reference<com::sun::star::frame::XModel> xModel;
- sal_Bool bFlat; //set true for export to flat .mml, set false for
- //export to a .sxm (or whatever) package
-public:
- SmXMLExportWrapper(com::sun::star::uno::Reference<com::sun::star::frame::XModel> &rRef)
- : xModel(rRef), bFlat(sal_True) {}
-
- sal_Bool Export(SfxMedium &rMedium);
- void SetFlat(sal_Bool bIn) {bFlat = bIn;}
-
- sal_Bool WriteThroughComponent(
- ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >
- xOutputStream,
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
- xComponent,
- ::com::sun::star::uno::Reference<
- ::com::sun::star::lang::XMultiServiceFactory > & rFactory,
- ::com::sun::star::uno::Reference<
- ::com::sun::star::beans::XPropertySet > & rPropSet,
- const sal_Char* pComponentName );
-
- sal_Bool WriteThroughComponent(
- const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStor,
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
- xComponent,
- const sal_Char* pStreamName,
- ::com::sun::star::uno::Reference<
- ::com::sun::star::lang::XMultiServiceFactory > & rFactory,
- ::com::sun::star::uno::Reference<
- ::com::sun::star::beans::XPropertySet > & rPropSet,
- const sal_Char* pComponentName,
- sal_Bool bCompress=sal_True );
-};
-
-////////////////////////////////////////////////////////////
-
-class SmXMLExport : public SvXMLExport
-{
- const SmNode * pTree;
- String aText;
- sal_Bool bSuccess;
-
-protected:
- void ExportNodes(const SmNode *pNode, int nLevel);
- void ExportTable(const SmNode *pNode, int nLevel);
- void ExportLine(const SmNode *pNode, int nLevel);
- void ExportExpression(const SmNode *pNode, int nLevel);
- void ExportText(const SmNode *pNode, int nLevel);
- void ExportMath(const SmNode *pNode, int nLevel);
- void ExportPolygon(const SmNode *pNode, int nLevel);
- void ExportBinaryHorizontal(const SmNode *pNode, int nLevel);
- void ExportUnaryHorizontal(const SmNode *pNode, int nLevel);
- void ExportBrace(const SmNode *pNode, int nLevel);
- void ExportBinaryVertical(const SmNode *pNode, int nLevel);
- void ExportSubSupScript(const SmNode *pNode, int nLevel);
- void ExportRoot(const SmNode *pNode, int nLevel);
- void ExportOperator(const SmNode *pNode, int nLevel);
- void ExportAttributes(const SmNode *pNode, int nLevel);
- void ExportFont(const SmNode *pNode, int nLevel);
- void ExportVerticalBrace(const SmNode *pNode, int nLevel);
- void ExportMatrix(const SmNode *pNode, int nLevel);
- void ExportBlank(const SmNode *pNode, int nLevel);
-
-public:
- // #110680#
- SmXMLExport(
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
- sal_uInt16 nExportFlags=EXPORT_ALL);
- virtual ~SmXMLExport() {};
-
- // XServiceInfo (override parent method)
- ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
-
- // XUnoTunnel
- sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw(::com::sun::star::uno::RuntimeException);
- static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId() throw();
-
- void _ExportAutoStyles() {}
- void _ExportMasterStyles() {}
- void _ExportContent();
- sal_uInt32 exportDoc(enum ::xmloff::token::XMLTokenEnum eClass);
-
- virtual void GetViewSettings(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aProps);
- virtual void GetConfigurationSettings(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aProps);
-
- sal_Bool GetSuccess() {return bSuccess;}
-};
-
-////////////////////////////////////////////////////////////
-
-#endif
-
+/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _MATHMLEXPORT_HXX_ +#define _MATHMLEXPORT_HXX_ + +#include <xmloff/xmlimp.hxx> +#include <xmloff/xmlexp.hxx> +#include <xmloff/DocumentSettingsContext.hxx> +#include <xmloff/xmltoken.hxx> + +#include <node.hxx> + +class SfxMedium; +namespace com { namespace sun { namespace star { + namespace io { + class XInputStream; + class XOutputStream; } + namespace beans { + class XPropertySet; } +} } } + + +//////////////////////////////////////////////////////////// + +class SmXMLExportWrapper +{ + com::sun::star::uno::Reference<com::sun::star::frame::XModel> xModel; + sal_Bool bFlat; //set true for export to flat .mml, set false for + //export to a .sxm (or whatever) package +public: + SmXMLExportWrapper(com::sun::star::uno::Reference<com::sun::star::frame::XModel> &rRef) + : xModel(rRef), bFlat(sal_True) {} + + sal_Bool Export(SfxMedium &rMedium); + void SetFlat(sal_Bool bIn) {bFlat = bIn;} + + sal_Bool WriteThroughComponent( + ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > + xOutputStream, + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > + xComponent, + ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XMultiServiceFactory > & rFactory, + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > & rPropSet, + const sal_Char* pComponentName ); + + sal_Bool WriteThroughComponent( + const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStor, + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > + xComponent, + const sal_Char* pStreamName, + ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XMultiServiceFactory > & rFactory, + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > & rPropSet, + const sal_Char* pComponentName, + sal_Bool bCompress=sal_True ); +}; + +//////////////////////////////////////////////////////////// + +class SmXMLExport : public SvXMLExport +{ + const SmNode * pTree; + String aText; + sal_Bool bSuccess; + +protected: + void ExportNodes(const SmNode *pNode, int nLevel); + void ExportTable(const SmNode *pNode, int nLevel); + void ExportLine(const SmNode *pNode, int nLevel); + void ExportExpression(const SmNode *pNode, int nLevel); + void ExportText(const SmNode *pNode, int nLevel); + void ExportMath(const SmNode *pNode, int nLevel); + void ExportPolygon(const SmNode *pNode, int nLevel); + void ExportBinaryHorizontal(const SmNode *pNode, int nLevel); + void ExportUnaryHorizontal(const SmNode *pNode, int nLevel); + void ExportBrace(const SmNode *pNode, int nLevel); + void ExportBinaryVertical(const SmNode *pNode, int nLevel); + void ExportSubSupScript(const SmNode *pNode, int nLevel); + void ExportRoot(const SmNode *pNode, int nLevel); + void ExportOperator(const SmNode *pNode, int nLevel); + void ExportAttributes(const SmNode *pNode, int nLevel); + void ExportFont(const SmNode *pNode, int nLevel); + void ExportVerticalBrace(const SmNode *pNode, int nLevel); + void ExportMatrix(const SmNode *pNode, int nLevel); + void ExportBlank(const SmNode *pNode, int nLevel); + +public: + // #110680# + SmXMLExport( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory, + sal_uInt16 nExportFlags=EXPORT_ALL); + virtual ~SmXMLExport() {}; + + // XServiceInfo (override parent method) + ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ); + + // XUnoTunnel + sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw(::com::sun::star::uno::RuntimeException); + static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId() throw(); + + void _ExportAutoStyles() {} + void _ExportMasterStyles() {} + void _ExportContent(); + sal_uInt32 exportDoc(enum ::xmloff::token::XMLTokenEnum eClass); + + virtual void GetViewSettings(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aProps); + virtual void GetConfigurationSettings(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aProps); + + sal_Bool GetSuccess() {return bSuccess;} +}; + +//////////////////////////////////////////////////////////// + +#endif + diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx index 1f7336db6d3c..dd90caaf6d45 100644 --- a/starmath/source/mathmlimport.cxx +++ b/starmath/source/mathmlimport.cxx @@ -1,3189 +1,3187 @@ -/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: x $
- * $Revision: 1.00 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_starmath.hxx"
-
-/*todo: Change characters and tcharacters to accumulate the characters together
-into one string, xml parser hands them to us line by line rather than all in
-one go*/
-
-#include <com/sun/star/xml/sax/XErrorHandler.hpp>
-#include <com/sun/star/xml/sax/XEntityResolver.hpp>
-#include <com/sun/star/xml/sax/InputSource.hpp>
-#include <com/sun/star/xml/sax/XDTDHandler.hpp>
-#include <com/sun/star/xml/sax/XParser.hpp>
-#include <com/sun/star/io/XActiveDataSource.hpp>
-#include <com/sun/star/io/XActiveDataControl.hpp>
-#include <com/sun/star/document/XDocumentProperties.hpp>
-#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
-#include <com/sun/star/packages/zip/ZipIOException.hpp>
-#include <com/sun/star/task/XStatusIndicatorFactory.hpp>
-#include <com/sun/star/beans/PropertyAttribute.hpp>
-#include <com/sun/star/container/XNameAccess.hpp>
-#include <com/sun/star/embed/ElementModes.hpp>
-#include <com/sun/star/uno/Any.h>
-
-#include <rtl/math.hxx>
-#include <sfx2/frame.hxx>
-#include <sfx2/docfile.hxx>
-#include <tools/debug.hxx>
-#include <tools/urlobj.hxx>
-#include <svtools/sfxecode.hxx>
-#include <svtools/saveopt.hxx>
-#include <svtools/stritem.hxx>
-#include <svtools/itemprop.hxx>
-#include <unotools/processfactory.hxx>
-#include <unotools/streamwrap.hxx>
-#include <xmloff/xmlnmspe.hxx>
-#include <xmloff/xmltoken.hxx>
-#include <xmloff/nmspmap.hxx>
-#include <xmloff/attrlist.hxx>
-#include <xmloff/xmluconv.hxx>
-#include <xmloff/xmlmetai.hxx>
-#include <osl/mutex.hxx>
-#include <comphelper/genericpropertyset.hxx>
-
-#include <memory>
-
-#include "mathmlimport.hxx"
-#include "mathtype.hxx"
-#include <starmath.hrc>
-#include <unomodel.hxx>
-#include <document.hxx>
-#include <utility.hxx>
-
-using namespace ::com::sun::star::beans;
-using namespace ::com::sun::star::container;
-using namespace ::com::sun::star::document;
-using namespace ::com::sun::star::lang;
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star;
-using namespace ::xmloff::token;
-
-using ::rtl::OUString;
-using ::rtl::OUStringBuffer;
-
-#define IMPORT_SVC_NAME RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.XMLImportFilter")
-
-#undef WANTEXCEPT
-
-////////////////////////////////////////////////////////////
-
-ULONG SmXMLImportWrapper::Import(SfxMedium &rMedium)
-{
- ULONG nError = ERRCODE_SFX_DOLOADFAILED;
-
- uno::Reference<lang::XMultiServiceFactory> xServiceFactory(
- utl::getProcessServiceFactory());
- DBG_ASSERT(xServiceFactory.is(), "XMLReader::Read: got no service manager");
- if ( !xServiceFactory.is() )
- return nError;
-
- //Make a model component from our SmModel
- uno::Reference< lang::XComponent > xModelComp( xModel, uno::UNO_QUERY );
- DBG_ASSERT( xModelComp.is(), "XMLReader::Read: got no model" );
-
- // try to get an XStatusIndicator from the Medium
- uno::Reference<task::XStatusIndicator> xStatusIndicator;
-
- sal_Bool bEmbedded = sal_False;
- uno::Reference <lang::XUnoTunnel> xTunnel;
- xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY);
- SmModel *pModel = reinterpret_cast<SmModel *>
- (xTunnel->getSomething(SmModel::getUnoTunnelId()));
-
- SmDocShell *pDocShell = pModel ?
- static_cast<SmDocShell*>(pModel->GetObjectShell()) : 0;
- if (pDocShell)
- {
-// if (pDocShell->GetMedium())
- {
- DBG_ASSERT( pDocShell->GetMedium() == &rMedium,
- "different SfxMedium found" );
-
- SfxItemSet* pSet = rMedium.GetItemSet();
- if (pSet)
- {
- const SfxUnoAnyItem* pItem = static_cast<const SfxUnoAnyItem*>(
- pSet->GetItem(SID_PROGRESS_STATUSBAR_CONTROL) );
- if (pItem)
- pItem->GetValue() >>= xStatusIndicator;
- }
- }
-
- if ( SFX_CREATE_MODE_EMBEDDED == pDocShell->GetCreateMode() )
- bEmbedded = sal_True;
- }
-
- comphelper::PropertyMapEntry aInfoMap[] =
- {
- { "PrivateData", sizeof("PrivateData")-1, 0,
- &::getCppuType( (Reference<XInterface> *)0 ),
- beans::PropertyAttribute::MAYBEVOID, 0 },
- { "BaseURI", sizeof("BaseURI")-1, 0,
- &::getCppuType( (OUString *)0 ),
- beans::PropertyAttribute::MAYBEVOID, 0 },
- { "StreamRelPath", sizeof("StreamRelPath")-1, 0,
- &::getCppuType( (OUString *)0 ),
- beans::PropertyAttribute::MAYBEVOID, 0 },
- { "StreamName", sizeof("StreamName")-1, 0,
- &::getCppuType( (OUString *)0 ),
- beans::PropertyAttribute::MAYBEVOID, 0 },
- { NULL, 0, 0, NULL, 0, 0 }
- };
- uno::Reference< beans::XPropertySet > xInfoSet(
- comphelper::GenericPropertySet_CreateInstance(
- new comphelper::PropertySetInfo( aInfoMap ) ) );
-
- // Set base URI
- OUString sPropName( RTL_CONSTASCII_USTRINGPARAM("BaseURI") );
- xInfoSet->setPropertyValue( sPropName, makeAny( rMedium.GetBaseURL() ) );
-
- sal_Int32 nSteps=3;
- if ( !(rMedium.IsStorage()))
- nSteps = 1;
-
- sal_Int32 nProgressRange(nSteps);
- if (xStatusIndicator.is())
- {
- xStatusIndicator->start(String(SmResId(STR_STATSTR_READING)),
- nProgressRange);
- }
-
- nSteps=0;
- if (xStatusIndicator.is())
- xStatusIndicator->setValue(nSteps++);
-
- if ( rMedium.IsStorage())
- {
- // TODO/LATER: handle the case of embedded links gracefully
- if ( bEmbedded ) // && !rMedium.GetStorage()->IsRoot() )
- {
- OUString aName( RTL_CONSTASCII_USTRINGPARAM( "dummyObjName" ) );
- if ( rMedium.GetItemSet() )
- {
- const SfxStringItem* pDocHierarchItem = static_cast<const SfxStringItem*>(
- rMedium.GetItemSet()->GetItem(SID_DOC_HIERARCHICALNAME) );
- if ( pDocHierarchItem )
- aName = pDocHierarchItem->GetValue();
- }
-
- if ( aName.getLength() )
- {
- sPropName = OUString(RTL_CONSTASCII_USTRINGPARAM("StreamRelPath"));
- xInfoSet->setPropertyValue( sPropName, makeAny( aName ) );
- }
- }
-
- sal_Bool bOASIS = ( SotStorage::GetVersion( rMedium.GetStorage() ) > SOFFICE_FILEFORMAT_60 );
- if (xStatusIndicator.is())
- xStatusIndicator->setValue(nSteps++);
-
- ULONG nWarn = ReadThroughComponent(
- rMedium.GetStorage(), xModelComp, "meta.xml", "Meta.xml",
- xServiceFactory, xInfoSet,
- (bOASIS ? "com.sun.star.comp.Math.XMLOasisMetaImporter"
- : "com.sun.star.comp.Math.XMLMetaImporter") );
-
- if ( nWarn != ERRCODE_IO_BROKENPACKAGE )
- {
- if (xStatusIndicator.is())
- xStatusIndicator->setValue(nSteps++);
-
- nWarn = ReadThroughComponent(
- rMedium.GetStorage(), xModelComp, "settings.xml", 0,
- xServiceFactory, xInfoSet,
- (bOASIS ? "com.sun.star.comp.Math.XMLOasisSettingsImporter"
- : "com.sun.star.comp.Math.XMLSettingsImporter" ) );
-
- if ( nWarn != ERRCODE_IO_BROKENPACKAGE )
- {
- if (xStatusIndicator.is())
- xStatusIndicator->setValue(nSteps++);
-
- nError = ReadThroughComponent(
- rMedium.GetStorage(), xModelComp, "content.xml", "Content.xml",
- xServiceFactory, xInfoSet, "com.sun.star.comp.Math.XMLImporter" );
- }
- else
- nError = ERRCODE_IO_BROKENPACKAGE;
- }
- else
- nError = ERRCODE_IO_BROKENPACKAGE;
- }
- else
- {
- Reference<io::XInputStream> xInputStream =
- new utl::OInputStreamWrapper(rMedium.GetInStream());
-
- if (xStatusIndicator.is())
- xStatusIndicator->setValue(nSteps++);
-
- nError = ReadThroughComponent( xInputStream, xModelComp,
- xServiceFactory, xInfoSet, "com.sun.star.comp.Math.XMLImporter", FALSE );
- }
-
- if (xStatusIndicator.is())
- xStatusIndicator->end();
- return nError;
-}
-
-
-/// read a component (file + filter version)
-ULONG SmXMLImportWrapper::ReadThroughComponent(
- Reference<io::XInputStream> xInputStream,
- Reference<XComponent> xModelComponent,
- Reference<lang::XMultiServiceFactory> & rFactory,
- Reference<beans::XPropertySet> & rPropSet,
- const sal_Char* pFilterName,
- sal_Bool bEncrypted )
-{
- ULONG nError = ERRCODE_SFX_DOLOADFAILED;
- DBG_ASSERT(xInputStream.is(), "input stream missing");
- DBG_ASSERT(xModelComponent.is(), "document missing");
- DBG_ASSERT(rFactory.is(), "factory missing");
- DBG_ASSERT(NULL != pFilterName,"I need a service name for the component!");
-
- // prepare ParserInputSrouce
- xml::sax::InputSource aParserInput;
- aParserInput.aInputStream = xInputStream;
-
- // get parser
- Reference< xml::sax::XParser > xParser(
- rFactory->createInstance(
- OUString::createFromAscii("com.sun.star.xml.sax.Parser") ),
- UNO_QUERY );
- DBG_ASSERT( xParser.is(), "Can't create parser" );
- if ( !xParser.is() )
- return nError;
-
- Sequence<Any> aArgs( 1 );
- aArgs[0] <<= rPropSet;
-
- // get filter
- Reference< xml::sax::XDocumentHandler > xFilter(
- rFactory->createInstanceWithArguments(
- OUString::createFromAscii(pFilterName), aArgs ),
- UNO_QUERY );
- DBG_ASSERT( xFilter.is(), "Can't instantiate filter component." );
- if ( !xFilter.is() )
- return nError;
-
- // connect parser and filter
- xParser->setDocumentHandler( xFilter );
-
- // connect model and filter
- Reference < XImporter > xImporter( xFilter, UNO_QUERY );
- xImporter->setTargetDocument( xModelComponent );
-
- // finally, parser the stream
- try
- {
- xParser->parseStream( aParserInput );
-
- uno::Reference<lang::XUnoTunnel> xFilterTunnel;
- xFilterTunnel = uno::Reference<lang::XUnoTunnel>
- ( xFilter, uno::UNO_QUERY );
- SmXMLImport *pFilter = reinterpret_cast< SmXMLImport * >(
- sal::static_int_cast< sal_uIntPtr >(
- xFilterTunnel->getSomething( SmXMLImport::getUnoTunnelId() )));
- if ( pFilter && pFilter->GetSuccess() )
- nError = 0;
- }
- catch( xml::sax::SAXParseException& r )
- {
- // sax parser sends wrapped exceptions,
- // try to find the original one
- xml::sax::SAXException aSaxEx = *(xml::sax::SAXException*)(&r);
- sal_Bool bTryChild = sal_True;
-
- while( bTryChild )
- {
- xml::sax::SAXException aTmp;
- if ( aSaxEx.WrappedException >>= aTmp )
- aSaxEx = aTmp;
- else
- bTryChild = sal_False;
- }
-
- packages::zip::ZipIOException aBrokenPackage;
- if ( aSaxEx.WrappedException >>= aBrokenPackage )
- return ERRCODE_IO_BROKENPACKAGE;
-
- if ( bEncrypted )
- nError = ERRCODE_SFX_WRONGPASSWORD;
- }
- catch( xml::sax::SAXException& r )
- {
- packages::zip::ZipIOException aBrokenPackage;
- if ( r.WrappedException >>= aBrokenPackage )
- return ERRCODE_IO_BROKENPACKAGE;
-
- if ( bEncrypted )
- nError = ERRCODE_SFX_WRONGPASSWORD;
- }
- catch( packages::zip::ZipIOException& )
- {
- nError = ERRCODE_IO_BROKENPACKAGE;
- }
- catch( io::IOException& )
- {
- }
-
- return nError;
-}
-
-
-ULONG SmXMLImportWrapper::ReadThroughComponent(
- const uno::Reference< embed::XStorage >& xStorage,
- Reference<XComponent> xModelComponent,
- const sal_Char* pStreamName,
- const sal_Char* pCompatibilityStreamName,
- Reference<lang::XMultiServiceFactory> & rFactory,
- Reference<beans::XPropertySet> & rPropSet,
- const sal_Char* pFilterName )
-{
- DBG_ASSERT(xStorage.is(), "Need storage!");
- DBG_ASSERT(NULL != pStreamName, "Please, please, give me a name!");
-
- // open stream (and set parser input)
- OUString sStreamName = OUString::createFromAscii(pStreamName);
- uno::Reference < container::XNameAccess > xAccess( xStorage, uno::UNO_QUERY );
- if ( !xAccess->hasByName(sStreamName) || !xStorage->isStreamElement(sStreamName) )
- {
- // stream name not found! Then try the compatibility name.
- // do we even have an alternative name?
- if ( pCompatibilityStreamName )
- sStreamName = OUString::createFromAscii(pCompatibilityStreamName);
- }
-
- // get input stream
- try
- {
- uno::Reference < io::XStream > xEventsStream = xStorage->openStreamElement( sStreamName, embed::ElementModes::READ );
-
- // determine if stream is encrypted or not
- uno::Reference < beans::XPropertySet > xProps( xEventsStream, uno::UNO_QUERY );
- Any aAny = xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Encrypted") ) );
- sal_Bool bEncrypted = sal_False;
- if ( aAny.getValueType() == ::getBooleanCppuType() )
- aAny >>= bEncrypted;
-
- // set Base URL
- if ( rPropSet.is() )
- {
- OUString sPropName( RTL_CONSTASCII_USTRINGPARAM("StreamName") );
- rPropSet->setPropertyValue( sPropName, makeAny( sStreamName ) );
- }
-
-
- Reference < io::XInputStream > xStream = xEventsStream->getInputStream();
- return ReadThroughComponent( xStream, xModelComponent, rFactory, rPropSet, pFilterName, bEncrypted );
- }
- catch ( packages::WrongPasswordException& )
- {
- return ERRCODE_SFX_WRONGPASSWORD;
- }
- catch( packages::zip::ZipIOException& )
- {
- return ERRCODE_IO_BROKENPACKAGE;
- }
- catch ( uno::Exception& )
- {
- }
-
- return ERRCODE_SFX_DOLOADFAILED;
-}
-
-////////////////////////////////////////////////////////////
-
-SmXMLImport::SmXMLImport(
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
- sal_uInt16 nImportFlags)
-: SvXMLImport( xServiceFactory, nImportFlags ),
- pPresLayoutElemTokenMap(0),
- pPresLayoutAttrTokenMap(0),
- pFencedAttrTokenMap(0),
- pOperatorAttrTokenMap(0),
- pAnnotationAttrTokenMap(0),
- pPresElemTokenMap(0),
- pPresScriptEmptyElemTokenMap(0),
- pPresTableElemTokenMap(0),
- pColorTokenMap(0),
- bSuccess(sal_False)
-{
-}
-
-const uno::Sequence< sal_Int8 > & SmXMLImport::getUnoTunnelId() throw()
-{
- static uno::Sequence< sal_Int8 > * pSeq = 0;
- if ( !pSeq )
- {
- osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
- if ( !pSeq )
- {
- static uno::Sequence< sal_Int8 > aSeq( 16 );
- rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
- pSeq = &aSeq;
- }
- }
- return *pSeq;
-}
-
-OUString SAL_CALL SmXMLImport_getImplementationName() throw()
-{
- return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLImporter" ) );
-}
-
-uno::Sequence< OUString > SAL_CALL SmXMLImport_getSupportedServiceNames()
- throw()
-{
- const OUString aServiceName( IMPORT_SVC_NAME );
- const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
- return aSeq;
-}
-
-uno::Reference< uno::XInterface > SAL_CALL SmXMLImport_createInstance(
- const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
- throw( uno::Exception )
-{
- // #110680#
- // return (cppu::OWeakObject*)new SmXMLImport(IMPORT_ALL);
- return (cppu::OWeakObject*)new SmXMLImport(rSMgr, IMPORT_ALL);
-}
-
-////////////////////////////////////////////////////////////
-
-OUString SAL_CALL SmXMLImportMeta_getImplementationName() throw()
-{
- return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLOasisMetaImporter" ) );
-}
-
-uno::Sequence< OUString > SAL_CALL SmXMLImportMeta_getSupportedServiceNames()
-throw()
-{
- const OUString aServiceName( IMPORT_SVC_NAME );
- const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
- return aSeq;
-}
-
-uno::Reference< uno::XInterface > SAL_CALL SmXMLImportMeta_createInstance(
- const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
-throw( uno::Exception )
-{
- // #110680#
- // return (cppu::OWeakObject*)new SmXMLImport( IMPORT_META );
- return (cppu::OWeakObject*)new SmXMLImport( rSMgr, IMPORT_META );
-}
-
-////////////////////////////////////////////////////////////
-
-OUString SAL_CALL SmXMLImportSettings_getImplementationName() throw()
-{
- return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLOasisSettingsImporter" ) );
-}
-
-uno::Sequence< OUString > SAL_CALL SmXMLImportSettings_getSupportedServiceNames()
- throw()
-{
- const OUString aServiceName( IMPORT_SVC_NAME );
- const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
- return aSeq;
-}
-
-uno::Reference< uno::XInterface > SAL_CALL SmXMLImportSettings_createInstance(
- const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
- throw( uno::Exception )
-{
- // #110680#
- // return (cppu::OWeakObject*)new SmXMLImport( IMPORT_SETTINGS );
- return (cppu::OWeakObject*)new SmXMLImport( rSMgr, IMPORT_SETTINGS );
-}
-
-////////////////////////////////////////////////////////////
-
-// XServiceInfo
-// override empty method from parent class
-rtl::OUString SAL_CALL SmXMLImport::getImplementationName()
- throw(uno::RuntimeException)
-{
- OUString aTxt;
- switch( getImportFlags() )
- {
- case IMPORT_META:
- aTxt = SmXMLImportMeta_getImplementationName();
- break;
- case IMPORT_SETTINGS:
- aTxt = SmXMLImportSettings_getImplementationName();
- break;
- case IMPORT_ALL:
- default:
- aTxt = SmXMLImport_getImplementationName();
- break;
- }
- return aTxt;
-}
-
-
-sal_Int64 SAL_CALL SmXMLImport::getSomething(
- const uno::Sequence< sal_Int8 >&rId )
-throw(uno::RuntimeException)
-{
- if ( rId.getLength() == 16 &&
- 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
- rId.getConstArray(), 16 ) )
- return sal::static_int_cast< sal_Int64 >(reinterpret_cast< sal_uIntPtr >(this));
-
- return SvXMLImport::getSomething( rId );
-}
-
-void SmXMLImport::endDocument(void)
- throw(xml::sax::SAXException, uno::RuntimeException)
-{
- //Set the resulted tree into the SmDocShell where it belongs
- SmNode *pTree;
- if (NULL != (pTree = GetTree()))
- {
- uno::Reference <frame::XModel> xModel = GetModel();
- uno::Reference <lang::XUnoTunnel> xTunnel;
- xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY);
- SmModel *pModel = reinterpret_cast<SmModel *>
- (xTunnel->getSomething(SmModel::getUnoTunnelId()));
-
- if (pModel)
- {
- SmDocShell *pDocShell =
- static_cast<SmDocShell*>(pModel->GetObjectShell());
- pDocShell->SetFormulaTree(pTree);
- if (0 == aText.Len()) //If we picked up no annotation text
- {
- //Make up some editable text
- aText = pDocShell->GetText();
- pTree->CreateTextFromNode(aText);
- aText.EraseTrailingChars();
- if ((aText.GetChar(0) == '{') &&
- (aText.GetChar(aText.Len()-1) == '}'))
- {
- aText.Erase(0,1);
- aText.Erase(aText.Len()-1,1);
- }
- }
- pDocShell->SetText( String() );
-
- // Convert symbol names
- SmParser &rParser = pDocShell->GetParser();
- BOOL bVal = rParser.IsImportSymbolNames();
- rParser.SetImportSymbolNames( TRUE );
- SmNode *pTmpTree = rParser.Parse( aText );
- aText = rParser.GetText();
- delete pTmpTree;
- rParser.SetImportSymbolNames( bVal );
-
- pDocShell->SetText( aText );
- }
- DBG_ASSERT(pModel,"So there *was* a uno problem after all");
-
- bSuccess = sal_True;
- }
-
- SvXMLImport::endDocument();
-}
-
-////////////////////////////////////////////////////////////
-
-class SmXMLImportContext: public SvXMLImportContext
-{
-public:
- SmXMLImportContext( SmXMLImport &rImport, sal_uInt16 nPrfx,
- const OUString& rLName)
- : SvXMLImportContext(rImport, nPrfx, rLName) {}
-
- const SmXMLImport& GetSmImport() const
- {
- return (const SmXMLImport&)GetImport();
- }
-
- SmXMLImport& GetSmImport()
- {
- return (SmXMLImport&)GetImport();
- }
-
- virtual void TCharacters(const OUString & /*rChars*/);
- virtual void Characters(const OUString &rChars);
- virtual SvXMLImportContext *CreateChildContext(sal_uInt16 /*nPrefix*/, const OUString& /*rLocalName*/, const uno::Reference< xml::sax::XAttributeList > & /*xAttrList*/);
-};
-
-void SmXMLImportContext::TCharacters(const OUString & /*rChars*/)
-{
-}
-
-void SmXMLImportContext::Characters(const OUString &rChars)
-{
- /*
- Whitespace occurring within the content of token elements is "trimmed"
- from the ends (i.e. all whitespace at the beginning and end of the
- content is removed), and "collapsed" internally (i.e. each sequence of
- 1 or more whitespace characters is replaced with one blank character).
- */
- //collapsing not done yet!
- const OUString &rChars2 = rChars.trim();
- if (rChars2.getLength())
- TCharacters(rChars2/*.collapse()*/);
-}
-
-SvXMLImportContext * SmXMLImportContext::CreateChildContext(sal_uInt16 /*nPrefix*/,
- const OUString& /*rLocalName*/,
- const uno::Reference< xml::sax::XAttributeList > & /*xAttrList*/)
-{
- return 0;
-}
-
-////////////////////////////////////////////////////////////
-
-struct SmXMLContext_Helper
-{
- sal_Int8 nIsBold;
- sal_Int8 nIsItalic;
- double nFontSize;
- sal_Bool bFontNodeNeeded;
- OUString sFontFamily;
- OUString sColor;
-
- SmXMLImportContext rContext;
-
- SmXMLContext_Helper(SmXMLImportContext &rImport) :
- nIsBold(-1), nIsItalic(-1), nFontSize(0.0), rContext(rImport) {}
-
- void RetrieveAttrs(const uno::Reference< xml::sax::XAttributeList > &xAttrList );
- void ApplyAttrs();
-};
-
-void SmXMLContext_Helper::RetrieveAttrs(const uno::Reference<
- xml::sax::XAttributeList > & xAttrList )
-{
- sal_Int8 nOldIsBold=nIsBold;
- sal_Int8 nOldIsItalic=nIsItalic;
- double nOldFontSize=nFontSize;
- sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
- OUString sOldFontFamily = sFontFamily;
- for (sal_Int16 i=0;i<nAttrCount;i++)
- {
- OUString sAttrName = xAttrList->getNameByIndex(i);
- OUString aLocalName;
- sal_uInt16 nPrefix = rContext.GetSmImport().GetNamespaceMap().
- GetKeyByAttrName(sAttrName,&aLocalName);
- OUString sValue = xAttrList->getValueByIndex(i);
- const SvXMLTokenMap &rAttrTokenMap =
- rContext.GetSmImport().GetPresLayoutAttrTokenMap();
- switch(rAttrTokenMap.Get(nPrefix,aLocalName))
- {
- case XML_TOK_FONTWEIGHT:
- nIsBold = sValue.equals(GetXMLToken(XML_BOLD));
- break;
- case XML_TOK_FONTSTYLE:
- nIsItalic = sValue.equals(GetXMLToken(XML_ITALIC));
- break;
- case XML_TOK_FONTSIZE:
- SvXMLUnitConverter::convertDouble(nFontSize,sValue);
- rContext.GetSmImport().GetMM100UnitConverter().
- setXMLMeasureUnit(MAP_POINT);
- if (-1 == sValue.indexOf(GetXMLToken(XML_UNIT_PT)))
- {
- if (-1 == sValue.indexOf('%'))
- nFontSize=0.0;
- else
- {
- rContext.GetSmImport().GetMM100UnitConverter().
- setXMLMeasureUnit(MAP_RELATIVE);
- }
- }
- break;
- case XML_TOK_FONTFAMILY:
- sFontFamily = sValue;
- break;
- case XML_TOK_COLOR:
- sColor = sValue;
- break;
- default:
- break;
- }
- }
-
- if ((nOldIsBold!=nIsBold) || (nOldIsItalic!=nIsItalic) ||
- (nOldFontSize!=nFontSize) || (sOldFontFamily!=sFontFamily)
- || sColor.getLength())
- bFontNodeNeeded=sal_True;
- else
- bFontNodeNeeded=sal_False;
-}
-
-void SmXMLContext_Helper::ApplyAttrs()
-{
- SmNodeStack &rNodeStack = rContext.GetSmImport().GetNodeStack();
-
- if (bFontNodeNeeded)
- {
- SmToken aToken;
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.nLevel = 5;
-
- if (nIsBold != -1)
- {
- if (nIsBold)
- aToken.eType = TBOLD;
- else
- aToken.eType = TNBOLD;
- SmStructureNode *pFontNode = static_cast<SmStructureNode *>
- (new SmFontNode(aToken));
- pFontNode->SetSubNodes(0,rNodeStack.Pop());
- rNodeStack.Push(pFontNode);
- }
- if (nIsItalic != -1)
- {
- if (nIsItalic)
- aToken.eType = TITALIC;
- else
- aToken.eType = TNITALIC;
- SmStructureNode *pFontNode = static_cast<SmStructureNode *>
- (new SmFontNode(aToken));
- pFontNode->SetSubNodes(0,rNodeStack.Pop());
- rNodeStack.Push(pFontNode);
- }
- if (nFontSize != 0.0)
- {
- aToken.eType = TSIZE;
- SmFontNode *pFontNode = new SmFontNode(aToken);
-
- if (MAP_RELATIVE == rContext.GetSmImport().GetMM100UnitConverter().
- getXMLMeasureUnit())
- {
- if (nFontSize < 100.00)
- pFontNode->SetSizeParameter(Fraction(100.00/nFontSize),
- FNTSIZ_DIVIDE);
- else
- pFontNode->SetSizeParameter(Fraction(nFontSize/100.00),
- FNTSIZ_MULTIPLY);
- }
- else
- pFontNode->SetSizeParameter(Fraction(nFontSize),FNTSIZ_ABSOLUT);
-
- pFontNode->SetSubNodes(0,rNodeStack.Pop());
- rNodeStack.Push(pFontNode);
- }
- if (sFontFamily.getLength())
- {
- if (sFontFamily.equalsIgnoreAsciiCase(GetXMLToken(XML_FIXED)))
- aToken.eType = TFIXED;
- else if (sFontFamily.equalsIgnoreAsciiCase(OUString(
- RTL_CONSTASCII_USTRINGPARAM("sans"))))
- aToken.eType = TSANS;
- else if (sFontFamily.equalsIgnoreAsciiCase(OUString(
- RTL_CONSTASCII_USTRINGPARAM("serif"))))
- aToken.eType = TSERIF;
- else //Just give up, we need to extend our font mechanism to be
- //more general
- return;
-
- aToken.aText = sFontFamily;
- SmFontNode *pFontNode = new SmFontNode(aToken);
- pFontNode->SetSubNodes(0,rNodeStack.Pop());
- rNodeStack.Push(pFontNode);
- }
- if (sColor.getLength())
- {
- //Again we can only handle a small set of colours in
- //StarMath for now.
- const SvXMLTokenMap& rTokenMap =
- rContext.GetSmImport().GetColorTokenMap();
- aToken.eType = static_cast<SmTokenType>(rTokenMap.Get(
- XML_NAMESPACE_MATH, sColor));
- if (aToken.eType != -1)
- {
- SmFontNode *pFontNode = new SmFontNode(aToken);
- pFontNode->SetSubNodes(0,rNodeStack.Pop());
- rNodeStack.Push(pFontNode);
- }
- }
-
- }
-}
-
-////////////////////////////////////////////////////////////
-
-class SmXMLDocContext_Impl : public SmXMLImportContext
-{
-public:
- SmXMLDocContext_Impl( SmXMLImport &rImport, sal_uInt16 nPrfx,
- const OUString& rLName)
- : SmXMLImportContext(rImport,nPrfx,rLName) {}
-
- virtual SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference< xml::sax::XAttributeList > &xAttrList);
-
- void EndElement();
-};
-
-////////////////////////////////////////////////////////////
-
-/*avert thy gaze from the proginator*/
-class SmXMLRowContext_Impl : public SmXMLDocContext_Impl
-{
-protected:
- ULONG nElementCount;
-
-public:
- SmXMLRowContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLDocContext_Impl(rImport,nPrefix,rLName)
- { nElementCount = GetSmImport().GetNodeStack().Count(); }
-
- virtual SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference< xml::sax::XAttributeList > &xAttrList);
-
- SvXMLImportContext *StrictCreateChildContext(sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference< xml::sax::XAttributeList > &xAttrList);
-
- void EndElement();
-};
-
-////////////////////////////////////////////////////////////
-
-class SmXMLFracContext_Impl : public SmXMLRowContext_Impl
-{
-public:
- SmXMLFracContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
-
- void EndElement();
-};
-
-////////////////////////////////////////////////////////////
-
-class SmXMLSqrtContext_Impl : public SmXMLRowContext_Impl
-{
-public:
- SmXMLSqrtContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
-
- void EndElement();
-};
-
-////////////////////////////////////////////////////////////
-
-class SmXMLRootContext_Impl : public SmXMLRowContext_Impl
-{
-public:
- SmXMLRootContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
-
- void EndElement();
-};
-
-////////////////////////////////////////////////////////////
-
-class SmXMLStyleContext_Impl : public SmXMLRowContext_Impl
-{
-protected:
- SmXMLContext_Helper aStyleHelper;
-
-public:
- /*Right now the style tag is completely ignored*/
- SmXMLStyleContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName) : SmXMLRowContext_Impl(rImport,nPrefix,rLName),
- aStyleHelper(*this) {}
-
- void EndElement();
- void StartElement(const uno::Reference< xml::sax::XAttributeList > &xAttrList );
-};
-
-void SmXMLStyleContext_Impl::StartElement(const uno::Reference<
- xml::sax::XAttributeList > & xAttrList )
-{
-#if 1
- aStyleHelper.RetrieveAttrs(xAttrList);
-#else
- sal_Int8 nOldIsBold=nIsBold;
- sal_Int8 nOldIsItalic=nIsItalic;
- double nOldFontSize=nFontSize;
- sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
- OUString sOldFontFamily = sFontFamily;
- for (sal_Int16 i=0;i<nAttrCount;i++)
- {
- OUString sAttrName = xAttrList->getNameByIndex(i);
- OUString aLocalName;
- sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
- GetKeyByAttrName(sAttrName,&aLocalName);
- OUString sValue = xAttrList->getValueByIndex(i);
- const SvXMLTokenMap &rAttrTokenMap =
- GetSmImport().GetPresLayoutAttrTokenMap();
- switch(rAttrTokenMap.Get(nPrefix,aLocalName))
- {
- case XML_TOK_FONTWEIGHT:
- nIsBold = sValue.equals(GetXMLToken(XML_BOLD));
- break;
- case XML_TOK_FONTSTYLE:
- nIsItalic = sValue.equals(GetXMLToken(XML_ITALIC));
- break;
- case XML_TOK_FONTSIZE:
- SvXMLUnitConverter::convertDouble(nFontSize,sValue);
- GetSmImport().GetMM100UnitConverter().
- setXMLMeasureUnit(MAP_POINT);
- if (-1 == sValue.indexOf(GetXMLToken(XML_UNIT_PT)))
- if (-1 == sValue.indexOf('%'))
- nFontSize=0.0;
- else
- {
- GetSmImport().GetMM100UnitConverter().
- setXMLMeasureUnit(MAP_RELATIVE);
- }
- break;
- case XML_TOK_FONTFAMILY:
- sFontFamily = sValue;
- break;
- case XML_TOK_COLOR:
- sColor = sValue;
- break;
- default:
- break;
- }
- }
-
- if ((nOldIsBold!=nIsBold) || (nOldIsItalic!=nIsItalic) ||
- (nOldFontSize!=nFontSize) || (sOldFontFamily!=sFontFamily)
- || sColor.getLength())
- bFontNodeNeeded=sal_True;
- else
- bFontNodeNeeded=sal_False;
-#endif
-}
-
-
-void SmXMLStyleContext_Impl::EndElement()
-{
- /*
- <mstyle> accepts any number of arguments; if this number is not 1, its
- contents are treated as a single "inferred <mrow>" containing its
- arguments
- */
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
- if (rNodeStack.Count() - nElementCount > 1)
- SmXMLRowContext_Impl::EndElement();
-#if 1
- aStyleHelper.ApplyAttrs();
-#else
- if (bFontNodeNeeded)
- {
- SmToken aToken;
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.nLevel = 5;
-
- if (nIsBold != -1)
- {
- if (nIsBold)
- aToken.eType = TBOLD;
- else
- aToken.eType = TNBOLD;
- SmStructureNode *pFontNode = static_cast<SmStructureNode *>
- (new SmFontNode(aToken));
- pFontNode->SetSubNodes(0,rNodeStack.Pop());
- rNodeStack.Push(pFontNode);
- }
- if (nIsItalic != -1)
- {
- if (nIsItalic)
- aToken.eType = TITALIC;
- else
- aToken.eType = TNITALIC;
- SmStructureNode *pFontNode = static_cast<SmStructureNode *>
- (new SmFontNode(aToken));
- pFontNode->SetSubNodes(0,rNodeStack.Pop());
- rNodeStack.Push(pFontNode);
- }
- if (nFontSize != 0.0)
- {
- aToken.eType = TSIZE;
- SmFontNode *pFontNode = new SmFontNode(aToken);
-
- if (MAP_RELATIVE == GetSmImport().GetMM100UnitConverter().
- getXMLMeasureUnit())
- {
- if (nFontSize < 100.00)
- pFontNode->SetSizeParameter(Fraction(100.00/nFontSize),
- FNTSIZ_DIVIDE);
- else
- pFontNode->SetSizeParameter(Fraction(nFontSize/100.00),
- FNTSIZ_MULTIPLY);
- }
- else
- pFontNode->SetSizeParameter(Fraction(nFontSize),FNTSIZ_ABSOLUT);
-
- pFontNode->SetSubNodes(0,rNodeStack.Pop());
- rNodeStack.Push(pFontNode);
- }
- if (sFontFamily.getLength())
- {
- if (sFontFamily.equalsIgnoreCase(GetXMLToken(XML_FIXED)))
- aToken.eType = TFIXED;
- else if (sFontFamily.equalsIgnoreCase(OUString(
- RTL_CONSTASCII_USTRINGPARAM("sans"))))
- aToken.eType = TSANS;
- else if (sFontFamily.equalsIgnoreCase(OUString(
- RTL_CONSTASCII_USTRINGPARAM("serif"))))
- aToken.eType = TSERIF;
- else //Just give up, we need to extend our font mechanism to be
- //more general
- return;
-
- aToken.aText = sFontFamily;
- SmFontNode *pFontNode = new SmFontNode(aToken);
- pFontNode->SetSubNodes(0,rNodeStack.Pop());
- rNodeStack.Push(pFontNode);
- }
- if (sColor.getLength())
- {
- //Again we can only handle a small set of colours in
- //StarMath for now.
- const SvXMLTokenMap& rTokenMap =
- GetSmImport().GetColorTokenMap();
- aToken.eType = static_cast<SmTokenType>(rTokenMap.Get(
- XML_NAMESPACE_MATH, sColor));
- if (aToken.eType != -1)
- {
- SmFontNode *pFontNode = new SmFontNode(aToken);
- pFontNode->SetSubNodes(0,rNodeStack.Pop());
- rNodeStack.Push(pFontNode);
- }
- }
-
- }
-#endif
-}
-
-////////////////////////////////////////////////////////////
-
-class SmXMLPaddedContext_Impl : public SmXMLRowContext_Impl
-{
-public:
- /*Right now the style tag is completely ignored*/
- SmXMLPaddedContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
-
- void EndElement();
-};
-
-void SmXMLPaddedContext_Impl::EndElement()
-{
- /*
- <mpadded> accepts any number of arguments; if this number is not 1, its
- contents are treated as a single "inferred <mrow>" containing its
- arguments
- */
- if (GetSmImport().GetNodeStack().Count() - nElementCount > 1)
- SmXMLRowContext_Impl::EndElement();
-}
-
-////////////////////////////////////////////////////////////
-
-class SmXMLPhantomContext_Impl : public SmXMLRowContext_Impl
-{
-public:
- /*Right now the style tag is completely ignored*/
- SmXMLPhantomContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
-
- void EndElement();
-};
-
-void SmXMLPhantomContext_Impl::EndElement()
-{
- /*
- <mphantom> accepts any number of arguments; if this number is not 1, its
- contents are treated as a single "inferred <mrow>" containing its
- arguments
- */
- if (GetSmImport().GetNodeStack().Count() - nElementCount > 1)
- SmXMLRowContext_Impl::EndElement();
-
- SmToken aToken;
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.nLevel = 5;
- aToken.eType = TPHANTOM;
-
- SmStructureNode *pPhantom = static_cast<SmStructureNode *>
- (new SmFontNode(aToken));
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
- pPhantom->SetSubNodes(0,rNodeStack.Pop());
- rNodeStack.Push(pPhantom);
-}
-
-////////////////////////////////////////////////////////////
-
-class SmXMLFencedContext_Impl : public SmXMLRowContext_Impl
-{
-protected:
- sal_Unicode cBegin;
- sal_Unicode cEnd;
-
-public:
- SmXMLFencedContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLRowContext_Impl(rImport,nPrefix,rLName),
- cBegin('('), cEnd(')') {}
-
- void StartElement(const uno::Reference< xml::sax::XAttributeList > & xAttrList );
- void EndElement();
-};
-
-
-void SmXMLFencedContext_Impl::StartElement(const uno::Reference<
- xml::sax::XAttributeList > & xAttrList )
-{
- sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
- for (sal_Int16 i=0;i<nAttrCount;i++)
- {
- OUString sAttrName = xAttrList->getNameByIndex(i);
- OUString aLocalName;
- sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
- GetKeyByAttrName(sAttrName,&aLocalName);
- OUString sValue = xAttrList->getValueByIndex(i);
- const SvXMLTokenMap &rAttrTokenMap =
- GetSmImport().GetFencedAttrTokenMap();
- switch(rAttrTokenMap.Get(nPrefix,aLocalName))
- {
- //temp, starmath cannot handle multichar brackets (I think)
- case XML_TOK_OPEN:
- cBegin = sValue[0];
- break;
- case XML_TOK_CLOSE:
- cEnd = sValue[0];
- break;
- default:
- /*Go to superclass*/
- break;
- }
- }
-}
-
-
-void SmXMLFencedContext_Impl::EndElement()
-{
- SmToken aToken;
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.aText = ',';
- aToken.eType = TLEFT;
- aToken.nLevel = 5;
-
- aToken.eType = TLPARENT;
- aToken.cMathChar = cBegin;
- SmStructureNode *pSNode = new SmBraceNode(aToken);
- SmNode *pLeft = new SmMathSymbolNode(aToken);
-
- aToken.cMathChar = cEnd;
- aToken.eType = TRPARENT;
- SmNode *pRight = new SmMathSymbolNode(aToken);
-
- SmNodeArray aRelationArray;
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
-
- aToken.cMathChar = '\0';
- aToken.aText = ',';
- aToken.eType = TIDENT;
-
- ULONG i = rNodeStack.Count() - nElementCount;
- if (rNodeStack.Count() - nElementCount > 1)
- i += rNodeStack.Count() - 1 - nElementCount;
- aRelationArray.resize(i);
- while (rNodeStack.Count() > nElementCount)
- {
- aRelationArray[--i] = rNodeStack.Pop();
- if (i > 1 && rNodeStack.Count() > 1)
- aRelationArray[--i] = new SmGlyphSpecialNode(aToken);
- }
-
- SmToken aDummy;
- SmStructureNode *pBody = new SmExpressionNode(aDummy);
- pBody->SetSubNodes(aRelationArray);
-
-
- pSNode->SetSubNodes(pLeft,pBody,pRight);
- pSNode->SetScaleMode(SCALE_HEIGHT);
- GetSmImport().GetNodeStack().Push(pSNode);
-}
-
-
-////////////////////////////////////////////////////////////
-
-class SmXMLErrorContext_Impl : public SmXMLRowContext_Impl
-{
-public:
- SmXMLErrorContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
-
- void EndElement();
-};
-
-void SmXMLErrorContext_Impl::EndElement()
-{
- /*Right now the error tag is completely ignored, what
- can I do with it in starmath, ?, maybe we need a
- report window ourselves, do a test for validity of
- the xml input, use merrors, and then generate
- the markup inside the merror with a big red colour
- of something. For now just throw them all away.
- */
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
- while (rNodeStack.Count() > nElementCount)
- {
- SmNode *pNode = rNodeStack.Pop();
- delete pNode;
- }
-}
-
-////////////////////////////////////////////////////////////
-
-class SmXMLNumberContext_Impl : public SmXMLImportContext
-{
-protected:
- SmToken aToken;
-
-public:
- SmXMLNumberContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLImportContext(rImport,nPrefix,rLName)
- {
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.nLevel = 5;
- aToken.eType = TNUMBER;
- }
-
- virtual void TCharacters(const OUString &rChars);
-
- void EndElement();
-};
-
-void SmXMLNumberContext_Impl::TCharacters(const OUString &rChars)
-{
- aToken.aText = rChars;
-}
-
-void SmXMLNumberContext_Impl::EndElement()
-{
- GetSmImport().GetNodeStack().Push(new SmTextNode(aToken,FNT_NUMBER));
-}
-
-////////////////////////////////////////////////////////////
-
-class SmXMLAnnotationContext_Impl : public SmXMLImportContext
-{
- sal_Bool bIsStarMath;
-
-public:
- SmXMLAnnotationContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLImportContext(rImport,nPrefix,rLName), bIsStarMath(sal_False) {}
-
- virtual void Characters(const OUString &rChars);
-
- void StartElement(const uno::Reference<xml::sax::XAttributeList > & xAttrList );
-};
-
-void SmXMLAnnotationContext_Impl::StartElement(const uno::Reference<
- xml::sax::XAttributeList > & xAttrList )
-{
- sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
- for (sal_Int16 i=0;i<nAttrCount;i++)
- {
- OUString sAttrName = xAttrList->getNameByIndex(i);
- OUString aLocalName;
- sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
- GetKeyByAttrName(sAttrName,&aLocalName);
-
- OUString sValue = xAttrList->getValueByIndex(i);
- const SvXMLTokenMap &rAttrTokenMap =
- GetSmImport().GetAnnotationAttrTokenMap();
- switch(rAttrTokenMap.Get(nPrefix,aLocalName))
- {
- case XML_TOK_ENCODING:
- bIsStarMath= sValue.equals(
- OUString(RTL_CONSTASCII_USTRINGPARAM("StarMath 5.0")));
- break;
- default:
- break;
- }
- }
-}
-
-void SmXMLAnnotationContext_Impl::Characters(const OUString &rChars)
-{
- if (bIsStarMath)
- GetSmImport().GetText().Append(String(rChars));
-}
-
-////////////////////////////////////////////////////////////
-
-class SmXMLTextContext_Impl : public SmXMLImportContext
-{
-protected:
- SmToken aToken;
-
-public:
- SmXMLTextContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLImportContext(rImport,nPrefix,rLName)
- {
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.nLevel = 5;
- aToken.eType = TTEXT;
- }
-
- virtual void TCharacters(const OUString &rChars);
-
- void EndElement();
-};
-
-void SmXMLTextContext_Impl::TCharacters(const OUString &rChars)
-{
- aToken.aText = rChars;
-}
-
-void SmXMLTextContext_Impl::EndElement()
-{
- GetSmImport().GetNodeStack().Push(new SmTextNode(aToken,FNT_TEXT));
-}
-
-////////////////////////////////////////////////////////////
-
-class SmXMLStringContext_Impl : public SmXMLImportContext
-{
-protected:
- SmToken aToken;
-
-public:
- SmXMLStringContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLImportContext(rImport,nPrefix,rLName)
- {
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.nLevel = 5;
- aToken.eType = TTEXT;
- }
-
- virtual void TCharacters(const OUString &rChars);
-
- void EndElement();
-};
-
-void SmXMLStringContext_Impl::TCharacters(const OUString &rChars)
-{
- /*
- The content of <ms> elements should be rendered with visible "escaping" of
- certain characters in the content, including at least "double quote"
- itself, and preferably whitespace other than individual blanks. The intent
- is for the viewer to see that the expression is a string literal, and to
- see exactly which characters form its content. For example, <ms>double
- quote is "</ms> might be rendered as "double quote is \"".
-
- Obviously this isn't fully done here.
- */
- aToken.aText.Erase();
- aToken.aText += '\"';
- aToken.aText += String(rChars);
- aToken.aText += '\"';
-}
-
-void SmXMLStringContext_Impl::EndElement()
-{
- GetSmImport().GetNodeStack().Push(new SmTextNode(aToken,FNT_FIXED));
-}
-
-////////////////////////////////////////////////////////////
-
-class SmXMLIdentifierContext_Impl : public SmXMLImportContext
-{
-protected:
- SmXMLContext_Helper aStyleHelper;
- SmToken aToken;
-
-public:
- SmXMLIdentifierContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLImportContext(rImport,nPrefix,rLName),aStyleHelper(*this)
- {
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.nLevel = 5;
- aToken.eType = TIDENT;
- }
-
- void TCharacters(const OUString &rChars);
- void StartElement(const uno::Reference< xml::sax::XAttributeList > & xAttrList )
- {
- aStyleHelper.RetrieveAttrs(xAttrList);
- };
- void EndElement();
-};
-
-void SmXMLIdentifierContext_Impl::EndElement()
-{
- SmTextNode *pNode = 0;
- //we will handle identifier italic/normal here instead of with a standalone
- //font node
- if (((aStyleHelper.nIsItalic == -1) && (aToken.aText.Len() > 1))
- || ((aStyleHelper.nIsItalic == 0) && (aToken.aText.Len() == 1)))
- {
- pNode = new SmTextNode(aToken,FNT_FUNCTION);
- pNode->GetFont().SetItalic(ITALIC_NONE);
- aStyleHelper.nIsItalic = -1;
- }
- else
- pNode = new SmTextNode(aToken,FNT_VARIABLE);
- if (aStyleHelper.bFontNodeNeeded && aStyleHelper.nIsItalic != -1)
- {
- if (aStyleHelper.nIsItalic)
- pNode->GetFont().SetItalic(ITALIC_NORMAL);
- else
- pNode->GetFont().SetItalic(ITALIC_NONE);
- }
-
- if ((-1!=aStyleHelper.nIsBold) || (0.0!=aStyleHelper.nFontSize) ||
- (aStyleHelper.sFontFamily.getLength()) ||
- aStyleHelper.sColor.getLength())
- aStyleHelper.bFontNodeNeeded=sal_True;
- else
- aStyleHelper.bFontNodeNeeded=sal_False;
- if (aStyleHelper.bFontNodeNeeded)
- aStyleHelper.ApplyAttrs();
- GetSmImport().GetNodeStack().Push(pNode);
-}
-
-void SmXMLIdentifierContext_Impl::TCharacters(const OUString &rChars)
-{
- aToken.aText = rChars;
-}
-
-////////////////////////////////////////////////////////////
-
-class SmXMLOperatorContext_Impl : public SmXMLImportContext
-{
- sal_Bool bIsStretchy;
-
-protected:
- SmToken aToken;
-
-public:
- SmXMLOperatorContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLImportContext(rImport,nPrefix,rLName), bIsStretchy(sal_False)
- {
- aToken.nGroup = 0;
- aToken.eType = TSPECIAL;
- aToken.nLevel = 5;
- }
-
- void TCharacters(const OUString &rChars);
- void StartElement(const uno::Reference< xml::sax::XAttributeList > &xAttrList );
- void EndElement();
-};
-
-void SmXMLOperatorContext_Impl::TCharacters(const OUString &rChars)
-{
- aToken.cMathChar = rChars[0];
-}
-
-void SmXMLOperatorContext_Impl::EndElement()
-{
- SmMathSymbolNode *pNode = new SmMathSymbolNode(aToken);
- //For stretchy scaling the scaling must be retrieved from this node
- //and applied to the expression itself so as to get the expression
- //to scale the operator to the height of the expression itself
- if (bIsStretchy)
- pNode->SetScaleMode(SCALE_HEIGHT);
- GetSmImport().GetNodeStack().Push(pNode);
-}
-
-
-
-void SmXMLOperatorContext_Impl::StartElement(const uno::Reference<
- xml::sax::XAttributeList > & xAttrList )
-{
- sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
- for (sal_Int16 i=0;i<nAttrCount;i++)
- {
- OUString sAttrName = xAttrList->getNameByIndex(i);
- OUString aLocalName;
- sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
- GetKeyByAttrName(sAttrName,&aLocalName);
-
- OUString sValue = xAttrList->getValueByIndex(i);
- const SvXMLTokenMap &rAttrTokenMap =
- GetSmImport().GetOperatorAttrTokenMap();
- switch(rAttrTokenMap.Get(nPrefix,aLocalName))
- {
- case XML_TOK_STRETCHY:
- bIsStretchy = sValue.equals(
- GetXMLToken(XML_TRUE));
- break;
- default:
- break;
- }
- }
-}
-
-
-////////////////////////////////////////////////////////////
-
-class SmXMLSpaceContext_Impl : public SmXMLImportContext
-{
-public:
- SmXMLSpaceContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLImportContext(rImport,nPrefix,rLName) {}
-
- void StartElement(const uno::Reference< xml::sax::XAttributeList >& xAttrList );
-};
-
-void SmXMLSpaceContext_Impl::StartElement(
- const uno::Reference<xml::sax::XAttributeList > & /*xAttrList*/ )
-{
- SmToken aToken;
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.eType = TBLANK;
- aToken.nLevel = 5;
- SmBlankNode *pBlank = new SmBlankNode(aToken);
- pBlank->IncreaseBy(aToken);
- GetSmImport().GetNodeStack().Push(pBlank);
-}
-
-////////////////////////////////////////////////////////////
-
-class SmXMLSubContext_Impl : public SmXMLRowContext_Impl
-{
-protected:
- void GenericEndElement(SmTokenType eType,SmSubSup aSubSup);
-
-public:
- SmXMLSubContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
-
- void EndElement()
- {
- GenericEndElement(TRSUB,RSUB);
- }
-};
-
-
-void SmXMLSubContext_Impl::GenericEndElement(SmTokenType eType, SmSubSup eSubSup)
-{
- /*The <msub> element requires exactly 2 arguments.*/
- DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount == 2,
- "Sub has not two arguments");
- SmToken aToken;
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.nLevel = 0;
- aToken.eType = eType;
- SmSubSupNode *pNode = new SmSubSupNode(aToken);
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
-
- // initialize subnodes array
- SmNodeArray aSubNodes;
- aSubNodes.resize(1 + SUBSUP_NUM_ENTRIES);
- for (ULONG i = 1; i < aSubNodes.size(); i++)
- aSubNodes[i] = NULL;
-
- aSubNodes[eSubSup+1] = rNodeStack.Pop();
- aSubNodes[0] = rNodeStack.Pop();
- pNode->SetSubNodes(aSubNodes);
- rNodeStack.Push(pNode);
-}
-
-////////////////////////////////////////////////////////////
-
-class SmXMLSupContext_Impl : public SmXMLSubContext_Impl
-{
-public:
- SmXMLSupContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLSubContext_Impl(rImport,nPrefix,rLName) {}
-
- void EndElement()
- {
- GenericEndElement(TRSUP,RSUP);
- }
-};
-
-////////////////////////////////////////////////////////////
-
-class SmXMLSubSupContext_Impl : public SmXMLRowContext_Impl
-{
-protected:
- void GenericEndElement(SmTokenType eType, SmSubSup aSub,SmSubSup aSup);
-
-public:
- SmXMLSubSupContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
-
- void EndElement()
- {
- GenericEndElement(TRSUB,RSUB,RSUP);
- }
-};
-
-void SmXMLSubSupContext_Impl::GenericEndElement(SmTokenType eType,
- SmSubSup aSub,SmSubSup aSup)
-{
- /*The <msub> element requires exactly 3 arguments.*/
- DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount == 3,
- "SubSup has not three arguments");
-
- SmToken aToken;
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.nLevel = 0;
- aToken.eType = eType;
- SmSubSupNode *pNode = new SmSubSupNode(aToken);
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
-
- // initialize subnodes array
- SmNodeArray aSubNodes;
- aSubNodes.resize(1 + SUBSUP_NUM_ENTRIES);
- for (ULONG i = 1; i < aSubNodes.size(); i++)
- aSubNodes[i] = NULL;
-
- aSubNodes[aSup+1] = rNodeStack.Pop();
- aSubNodes[aSub+1] = rNodeStack.Pop();
- aSubNodes[0] = rNodeStack.Pop();
- pNode->SetSubNodes(aSubNodes);
- rNodeStack.Push(pNode);
-}
-
-////////////////////////////////////////////////////////////
-
-class SmXMLUnderContext_Impl : public SmXMLSubContext_Impl
-{
-protected:
- sal_Int16 nAttrCount;
-
-public:
- SmXMLUnderContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLSubContext_Impl(rImport,nPrefix,rLName) {}
-
- void StartElement(const uno::Reference< xml::sax::XAttributeList > &xAttrList );
- void EndElement();
- void HandleAccent();
-};
-
-void SmXMLUnderContext_Impl::StartElement(const uno::Reference<
- xml::sax::XAttributeList > & xAttrList )
-{
- nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
-}
-
-void SmXMLUnderContext_Impl::HandleAccent()
-{
- DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount == 2,
- "Sub has not two arguments");
-
- /*Just one special case for the underline thing*/
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
- SmNode *pTest = rNodeStack.Pop();
- SmToken aToken;
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.nLevel = 0;
- aToken.eType = TUNDERLINE;
-
-
- SmNodeArray aSubNodes;
- aSubNodes.resize(2);
-
- SmStructureNode *pNode = new SmAttributNode(aToken);
- if ((pTest->GetToken().cMathChar & 0x0FFF) == 0x0332)
- {
- aSubNodes[0] = new SmRectangleNode(aToken);
- delete pTest;
- }
- else
- aSubNodes[0] = pTest;
-
- aSubNodes[1] = rNodeStack.Pop();
- pNode->SetSubNodes(aSubNodes);
- pNode->SetScaleMode(SCALE_WIDTH);
- rNodeStack.Push(pNode);
-}
-
-
-void SmXMLUnderContext_Impl::EndElement()
-{
- if (!nAttrCount)
- GenericEndElement(TCSUB,CSUB);
- else
- HandleAccent();
-#if 0
- //UnderBrace trick
- SmStructureNode *pNode = rNodeStack.Pop();
- if (pNode->GetSubNode(1)->GetToken().cMathChar == (0x0332|0xf000))
- if (pNode->GetSubNode(0)->GetToken().cMathChar == (0x0332|0xf000))
-#endif
-}
-
-////////////////////////////////////////////////////////////
-
-class SmXMLOverContext_Impl : public SmXMLSubContext_Impl
-{
-protected:
- sal_Int16 nAttrCount;
-
-public:
- SmXMLOverContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLSubContext_Impl(rImport,nPrefix,rLName), nAttrCount(0) {}
-
- void EndElement();
- void StartElement(const uno::Reference< xml::sax::XAttributeList > &xAttrList );
- void HandleAccent();
-};
-
-
-void SmXMLOverContext_Impl::StartElement(const uno::Reference<
- xml::sax::XAttributeList > & xAttrList )
-{
- nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
-}
-
-
-void SmXMLOverContext_Impl::EndElement()
-{
- if (!nAttrCount)
- GenericEndElement(TCSUP,CSUP);
- else
- HandleAccent();
-}
-
-
-void SmXMLOverContext_Impl::HandleAccent()
-{
- DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount == 2,
- "Sub has not two arguments");
- SmToken aToken;
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.nLevel = 0;
- aToken.eType = TACUTE;
-
- SmAttributNode *pNode = new SmAttributNode(aToken);
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
-
- SmNodeArray aSubNodes;
- aSubNodes.resize(2);
- aSubNodes[0] = rNodeStack.Pop();
- aSubNodes[1] = rNodeStack.Pop();
- pNode->SetSubNodes(aSubNodes);
- pNode->SetScaleMode(SCALE_WIDTH);
- rNodeStack.Push(pNode);
-
-}
-
-////////////////////////////////////////////////////////////
-
-class SmXMLUnderOverContext_Impl : public SmXMLSubSupContext_Impl
-{
-public:
- SmXMLUnderOverContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLSubSupContext_Impl(rImport,nPrefix,rLName) {}
-
- void EndElement()
- {
- GenericEndElement(TCSUB,CSUB,CSUP);
- }
-};
-
-////////////////////////////////////////////////////////////
-
-class SmXMLMultiScriptsContext_Impl : public SmXMLSubSupContext_Impl
-{
- sal_Bool bHasPrescripts;
-
-public:
- SmXMLMultiScriptsContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName) :
- SmXMLSubSupContext_Impl(rImport,nPrefix,rLName),
- bHasPrescripts(FALSE) {}
-
- void EndElement();
- void MiddleElement();
- SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference< xml::sax::XAttributeList > &xAttrList);
-};
-
-////////////////////////////////////////////////////////////
-
-class SmXMLNoneContext_Impl : public SmXMLImportContext
-{
-public:
- SmXMLNoneContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLImportContext(rImport,nPrefix,rLName) {}
-
- void EndElement();
-};
-
-
-void SmXMLNoneContext_Impl::EndElement(void)
-{
- SmToken aToken;
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.aText.Erase();
- aToken.nLevel = 5;
- aToken.eType = TIDENT;
- GetSmImport().GetNodeStack().Push(
- new SmTextNode(aToken,FNT_VARIABLE));
-}
-
-////////////////////////////////////////////////////////////
-
-class SmXMLPrescriptsContext_Impl : public SmXMLImportContext
-{
-public:
- SmXMLPrescriptsContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLImportContext(rImport,nPrefix,rLName) {}
-};
-
-////////////////////////////////////////////////////////////
-
-class SmXMLTableRowContext_Impl : public SmXMLRowContext_Impl
-{
-public:
- SmXMLTableRowContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName) :
- SmXMLRowContext_Impl(rImport,nPrefix,rLName)
- {}
-
- SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference< xml::sax::XAttributeList > &xAttrList);
-};
-
-
-////////////////////////////////////////////////////////////
-
-class SmXMLTableContext_Impl : public SmXMLTableRowContext_Impl
-{
-public:
- SmXMLTableContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName) :
- SmXMLTableRowContext_Impl(rImport,nPrefix,rLName)
- {}
-
- void EndElement();
- SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference< xml::sax::XAttributeList > &xAttrList);
-};
-
-
-////////////////////////////////////////////////////////////
-
-class SmXMLTableCellContext_Impl : public SmXMLRowContext_Impl
-{
-public:
- SmXMLTableCellContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName) :
- SmXMLRowContext_Impl(rImport,nPrefix,rLName)
- {}
-};
-
-////////////////////////////////////////////////////////////
-
-class SmXMLAlignGroupContext_Impl : public SmXMLRowContext_Impl
-{
-public:
- SmXMLAlignGroupContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName) :
- SmXMLRowContext_Impl(rImport,nPrefix,rLName)
- {}
-
- /*Don't do anything with alignment for now*/
- void EndElement()
- {
- }
-};
-
-////////////////////////////////////////////////////////////
-
-class SmXMLActionContext_Impl : public SmXMLRowContext_Impl
-{
-public:
- SmXMLActionContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName) :
- SmXMLRowContext_Impl(rImport,nPrefix,rLName)
- {}
-
- void EndElement();
-};
-
-////////////////////////////////////////////////////////////
-
-// NB: virtually inherit so we can multiply inherit properly
-// in SmXMLFlatDocContext_Impl
-class SmXMLOfficeContext_Impl : public virtual SvXMLImportContext
-{
-public:
- SmXMLOfficeContext_Impl( SmXMLImport &rImport, sal_uInt16 nPrfx,
- const OUString& rLName)
- : SvXMLImportContext(rImport,nPrfx,rLName) {}
-
- virtual SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference< xml::sax::XAttributeList > &xAttrList);
-};
-
-SvXMLImportContext *SmXMLOfficeContext_Impl::CreateChildContext(sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference< xml::sax::XAttributeList > &xAttrList)
-{
- SvXMLImportContext *pContext = 0;
- if ( XML_NAMESPACE_OFFICE == nPrefix &&
- rLocalName == GetXMLToken(XML_META) )
- {
- DBG_WARNING("XML_TOK_DOC_META: should not have come here, maybe document is invalid?");
- }
- else if ( XML_NAMESPACE_OFFICE == nPrefix &&
- rLocalName == GetXMLToken(XML_SETTINGS) )
- {
- pContext = new XMLDocumentSettingsContext( GetImport(),
- XML_NAMESPACE_OFFICE, rLocalName,
- xAttrList );
- }
- else
- pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
-
- return pContext;
-}
-
-////////////////////////////////////////////////////////////
-
-// context for flat file xml format
-class SmXMLFlatDocContext_Impl
- : public SmXMLOfficeContext_Impl, public SvXMLMetaDocumentContext
-{
-public:
- SmXMLFlatDocContext_Impl( SmXMLImport& i_rImport,
- USHORT i_nPrefix, const OUString & i_rLName,
- const uno::Reference<document::XDocumentProperties>& i_xDocProps,
- const uno::Reference<xml::sax::XDocumentHandler>& i_xDocBuilder);
-
- virtual ~SmXMLFlatDocContext_Impl();
-
- virtual SvXMLImportContext *CreateChildContext(USHORT i_nPrefix, const OUString& i_rLocalName, const uno::Reference<xml::sax::XAttributeList>& i_xAttrList);
-};
-
-SmXMLFlatDocContext_Impl::SmXMLFlatDocContext_Impl( SmXMLImport& i_rImport,
- USHORT i_nPrefix, const OUString & i_rLName,
- const uno::Reference<document::XDocumentProperties>& i_xDocProps,
- const uno::Reference<xml::sax::XDocumentHandler>& i_xDocBuilder) :
- SvXMLImportContext(i_rImport, i_nPrefix, i_rLName),
- SmXMLOfficeContext_Impl(i_rImport, i_nPrefix, i_rLName),
- SvXMLMetaDocumentContext(i_rImport, i_nPrefix, i_rLName,
- i_xDocProps, i_xDocBuilder)
-{
-}
-
-SmXMLFlatDocContext_Impl::~SmXMLFlatDocContext_Impl()
-{
-}
-
-SvXMLImportContext *SmXMLFlatDocContext_Impl::CreateChildContext(
- USHORT i_nPrefix, const OUString& i_rLocalName,
- const uno::Reference<xml::sax::XAttributeList>& i_xAttrList)
-{
- // behave like meta base class iff we encounter office:meta
- if ( XML_NAMESPACE_OFFICE == i_nPrefix &&
- i_rLocalName == GetXMLToken(XML_META) )
- {
- return SvXMLMetaDocumentContext::CreateChildContext(
- i_nPrefix, i_rLocalName, i_xAttrList );
- }
- else
- {
- return SmXMLOfficeContext_Impl::CreateChildContext(
- i_nPrefix, i_rLocalName, i_xAttrList );
- }
-}
-
-////////////////////////////////////////////////////////////
-
-static __FAR_DATA SvXMLTokenMapEntry aPresLayoutElemTokenMap[] =
-{
- { XML_NAMESPACE_MATH, XML_SEMANTICS, XML_TOK_SEMANTICS },
- { XML_NAMESPACE_MATH, XML_MATH, XML_TOK_MATH },
- { XML_NAMESPACE_MATH, XML_MSTYLE, XML_TOK_MSTYLE },
- { XML_NAMESPACE_MATH, XML_MERROR, XML_TOK_MERROR },
- { XML_NAMESPACE_MATH, XML_MPHANTOM, XML_TOK_MPHANTOM },
- { XML_NAMESPACE_MATH, XML_MROW, XML_TOK_MROW },
- { XML_NAMESPACE_MATH, XML_MFRAC, XML_TOK_MFRAC },
- { XML_NAMESPACE_MATH, XML_MSQRT, XML_TOK_MSQRT },
- { XML_NAMESPACE_MATH, XML_MROOT, XML_TOK_MROOT },
- { XML_NAMESPACE_MATH, XML_MSUB, XML_TOK_MSUB },
- { XML_NAMESPACE_MATH, XML_MSUP, XML_TOK_MSUP },
- { XML_NAMESPACE_MATH, XML_MSUBSUP, XML_TOK_MSUBSUP },
- { XML_NAMESPACE_MATH, XML_MUNDER, XML_TOK_MUNDER },
- { XML_NAMESPACE_MATH, XML_MOVER, XML_TOK_MOVER },
- { XML_NAMESPACE_MATH, XML_MUNDEROVER, XML_TOK_MUNDEROVER },
- { XML_NAMESPACE_MATH, XML_MMULTISCRIPTS, XML_TOK_MMULTISCRIPTS },
- { XML_NAMESPACE_MATH, XML_MTABLE, XML_TOK_MTABLE },
- { XML_NAMESPACE_MATH, XML_MACTION, XML_TOK_MACTION },
- { XML_NAMESPACE_MATH, XML_MFENCED, XML_TOK_MFENCED },
- { XML_NAMESPACE_MATH, XML_MPADDED, XML_TOK_MPADDED },
- XML_TOKEN_MAP_END
-};
-
-static __FAR_DATA SvXMLTokenMapEntry aPresLayoutAttrTokenMap[] =
-{
- { XML_NAMESPACE_MATH, XML_FONTWEIGHT, XML_TOK_FONTWEIGHT },
- { XML_NAMESPACE_MATH, XML_FONTSTYLE, XML_TOK_FONTSTYLE },
- { XML_NAMESPACE_MATH, XML_FONTSIZE, XML_TOK_FONTSIZE },
- { XML_NAMESPACE_MATH, XML_FONTFAMILY, XML_TOK_FONTFAMILY },
- { XML_NAMESPACE_MATH, XML_COLOR, XML_TOK_COLOR },
- XML_TOKEN_MAP_END
-};
-
-static __FAR_DATA SvXMLTokenMapEntry aFencedAttrTokenMap[] =
-{
- { XML_NAMESPACE_MATH, XML_OPEN, XML_TOK_OPEN },
- { XML_NAMESPACE_MATH, XML_CLOSE, XML_TOK_CLOSE },
- XML_TOKEN_MAP_END
-};
-
-static __FAR_DATA SvXMLTokenMapEntry aOperatorAttrTokenMap[] =
-{
- { XML_NAMESPACE_MATH, XML_STRETCHY, XML_TOK_STRETCHY },
- XML_TOKEN_MAP_END
-};
-
-static __FAR_DATA SvXMLTokenMapEntry aAnnotationAttrTokenMap[] =
-{
- { XML_NAMESPACE_MATH, XML_ENCODING, XML_TOK_ENCODING },
- XML_TOKEN_MAP_END
-};
-
-
-static __FAR_DATA SvXMLTokenMapEntry aPresElemTokenMap[] =
-{
- { XML_NAMESPACE_MATH, XML_ANNOTATION, XML_TOK_ANNOTATION },
- { XML_NAMESPACE_MATH, XML_MI, XML_TOK_MI },
- { XML_NAMESPACE_MATH, XML_MN, XML_TOK_MN },
- { XML_NAMESPACE_MATH, XML_MO, XML_TOK_MO },
- { XML_NAMESPACE_MATH, XML_MTEXT, XML_TOK_MTEXT },
- { XML_NAMESPACE_MATH, XML_MSPACE,XML_TOK_MSPACE },
- { XML_NAMESPACE_MATH, XML_MS, XML_TOK_MS },
- { XML_NAMESPACE_MATH, XML_MALIGNGROUP, XML_TOK_MALIGNGROUP },
- XML_TOKEN_MAP_END
-};
-
-static __FAR_DATA SvXMLTokenMapEntry aPresScriptEmptyElemTokenMap[] =
-{
- { XML_NAMESPACE_MATH, XML_MPRESCRIPTS, XML_TOK_MPRESCRIPTS },
- { XML_NAMESPACE_MATH, XML_NONE, XML_TOK_NONE },
- XML_TOKEN_MAP_END
-};
-
-static __FAR_DATA SvXMLTokenMapEntry aPresTableElemTokenMap[] =
-{
- { XML_NAMESPACE_MATH, XML_MTR, XML_TOK_MTR },
- { XML_NAMESPACE_MATH, XML_MTD, XML_TOK_MTD },
- XML_TOKEN_MAP_END
-};
-
-static __FAR_DATA SvXMLTokenMapEntry aColorTokenMap[] =
-{
- { XML_NAMESPACE_MATH, XML_BLACK, TBLACK},
- { XML_NAMESPACE_MATH, XML_WHITE, TWHITE},
- { XML_NAMESPACE_MATH, XML_RED, TRED},
- { XML_NAMESPACE_MATH, XML_GREEN, TGREEN},
- { XML_NAMESPACE_MATH, XML_BLUE, TBLUE},
- { XML_NAMESPACE_MATH, XML_AQUA, TCYAN},
- { XML_NAMESPACE_MATH, XML_FUCHSIA, TMAGENTA},
- { XML_NAMESPACE_MATH, XML_YELLOW, TYELLOW},
- XML_TOKEN_MAP_END
-};
-
-
-////////////////////////////////////////////////////////////
-
-const SvXMLTokenMap& SmXMLImport::GetPresLayoutElemTokenMap()
-{
- if (!pPresLayoutElemTokenMap)
- pPresLayoutElemTokenMap = new SvXMLTokenMap(aPresLayoutElemTokenMap);
- return *pPresLayoutElemTokenMap;
-}
-
-const SvXMLTokenMap& SmXMLImport::GetPresLayoutAttrTokenMap()
-{
- if (!pPresLayoutAttrTokenMap)
- pPresLayoutAttrTokenMap = new SvXMLTokenMap(aPresLayoutAttrTokenMap);
- return *pPresLayoutAttrTokenMap;
-}
-
-
-const SvXMLTokenMap& SmXMLImport::GetFencedAttrTokenMap()
-{
- if (!pFencedAttrTokenMap)
- pFencedAttrTokenMap = new SvXMLTokenMap(aFencedAttrTokenMap);
- return *pFencedAttrTokenMap;
-}
-
-const SvXMLTokenMap& SmXMLImport::GetOperatorAttrTokenMap()
-{
- if (!pOperatorAttrTokenMap)
- pOperatorAttrTokenMap = new SvXMLTokenMap(aOperatorAttrTokenMap);
- return *pOperatorAttrTokenMap;
-}
-
-const SvXMLTokenMap& SmXMLImport::GetAnnotationAttrTokenMap()
-{
- if (!pAnnotationAttrTokenMap)
- pAnnotationAttrTokenMap = new SvXMLTokenMap(aAnnotationAttrTokenMap);
- return *pAnnotationAttrTokenMap;
-}
-
-const SvXMLTokenMap& SmXMLImport::GetPresElemTokenMap()
-{
- if (!pPresElemTokenMap)
- pPresElemTokenMap = new SvXMLTokenMap(aPresElemTokenMap);
- return *pPresElemTokenMap;
-}
-
-const SvXMLTokenMap& SmXMLImport::GetPresScriptEmptyElemTokenMap()
-{
- if (!pPresScriptEmptyElemTokenMap)
- pPresScriptEmptyElemTokenMap = new
- SvXMLTokenMap(aPresScriptEmptyElemTokenMap);
- return *pPresScriptEmptyElemTokenMap;
-}
-
-const SvXMLTokenMap& SmXMLImport::GetPresTableElemTokenMap()
-{
- if (!pPresTableElemTokenMap)
- pPresTableElemTokenMap = new SvXMLTokenMap(aPresTableElemTokenMap);
- return *pPresTableElemTokenMap;
-}
-
-const SvXMLTokenMap& SmXMLImport::GetColorTokenMap()
-{
- if (!pColorTokenMap)
- pColorTokenMap = new SvXMLTokenMap(aColorTokenMap);
- return *pColorTokenMap;
-}
-
-////////////////////////////////////////////////////////////
-
-SvXMLImportContext *SmXMLDocContext_Impl::CreateChildContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference<xml::sax::XAttributeList>& xAttrList)
-{
- SvXMLImportContext* pContext = 0L;
-
- const SvXMLTokenMap& rTokenMap = GetSmImport().GetPresLayoutElemTokenMap();
-
- //UINT32 nTest = rTokenMap.Get(nPrefix, rLocalName);
-
- switch(rTokenMap.Get(nPrefix, rLocalName))
- {
- //Consider semantics a dummy except for any starmath annotations
- case XML_TOK_SEMANTICS:
- pContext = GetSmImport().CreateRowContext(nPrefix,rLocalName,
- xAttrList);
- break;
- /*General Layout Schemata*/
- case XML_TOK_MROW:
- pContext = GetSmImport().CreateRowContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MFRAC:
- pContext = GetSmImport().CreateFracContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MSQRT:
- pContext = GetSmImport().CreateSqrtContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MROOT:
- pContext = GetSmImport().CreateRootContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MSTYLE:
- pContext = GetSmImport().CreateStyleContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MERROR:
- pContext = GetSmImport().CreateErrorContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MPADDED:
- pContext = GetSmImport().CreatePaddedContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MPHANTOM:
- pContext = GetSmImport().CreatePhantomContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MFENCED:
- pContext = GetSmImport().CreateFencedContext(nPrefix,rLocalName,
- xAttrList);
- break;
- /*Script and Limit Schemata*/
- case XML_TOK_MSUB:
- pContext = GetSmImport().CreateSubContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MSUP:
- pContext = GetSmImport().CreateSupContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MSUBSUP:
- pContext = GetSmImport().CreateSubSupContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MUNDER:
- pContext = GetSmImport().CreateUnderContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MOVER:
- pContext = GetSmImport().CreateOverContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MUNDEROVER:
- pContext = GetSmImport().CreateUnderOverContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MMULTISCRIPTS:
- pContext = GetSmImport().CreateMultiScriptsContext(nPrefix,
- rLocalName, xAttrList);
- break;
- case XML_TOK_MTABLE:
- pContext = GetSmImport().CreateTableContext(nPrefix,
- rLocalName, xAttrList);
- break;
- case XML_TOK_MACTION:
- pContext = GetSmImport().CreateActionContext(nPrefix,
- rLocalName, xAttrList);
- break;
- default:
- /*Basically theres an implicit mrow around certain bare
- *elements, use a RowContext to see if this is one of
- *those ones*/
- SmXMLRowContext_Impl aTempContext(GetSmImport(),nPrefix,
- GetXMLToken(XML_MROW));
-
- pContext = aTempContext.StrictCreateChildContext(nPrefix,
- rLocalName, xAttrList);
- break;
- }
- return pContext;
-}
-
-void SmXMLDocContext_Impl::EndElement()
-{
- SmNodeArray ContextArray;
- ContextArray.resize(1);
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
-
- for (ULONG i=0;i< 1;i++)
- ContextArray[i] = rNodeStack.Pop();
-
- SmToken aDummy;
- SmStructureNode *pSNode = new SmLineNode(aDummy);
- pSNode->SetSubNodes(ContextArray);
- rNodeStack.Push(pSNode);
-
- SmNodeArray LineArray;
- ULONG n = rNodeStack.Count();
- LineArray.resize(n);
- for (ULONG j = 0; j < n; j++)
- LineArray[n - (j + 1)] = rNodeStack.Pop();
- SmStructureNode *pSNode2 = new SmTableNode(aDummy);
- pSNode2->SetSubNodes(LineArray);
- rNodeStack.Push(pSNode2);
-}
-
-void SmXMLFracContext_Impl::EndElement()
-{
- SmToken aToken;
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.nLevel = 0;
- aToken.eType = TOVER;
- SmStructureNode *pSNode = new SmBinVerNode(aToken);
- SmNode *pOper = new SmRectangleNode(aToken);
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
- DBG_ASSERT(rNodeStack.Count() - nElementCount == 2,
- "Fraction (mfrac) tag is missing component");
- if (rNodeStack.Count() - nElementCount == 2)
- {
- SmNode *pSecond = rNodeStack.Pop();
- SmNode *pFirst = rNodeStack.Pop();
- pSNode->SetSubNodes(pFirst,pOper,pSecond);
- rNodeStack.Push(pSNode);
- }
-}
-
-void SmXMLRootContext_Impl::EndElement()
-{
- /*The <mroot> element requires exactly 2 arguments.*/
- DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount == 2,
- "Root tag is missing component");
-
- SmToken aToken;
- aToken.cMathChar = MS_SQRT; //Temporary: alert, based on StarSymbol font
- aToken.nGroup = 0;
- aToken.nLevel = 0;
- aToken.eType = TNROOT;
- SmStructureNode *pSNode = new SmRootNode(aToken);
- SmNode *pOper = new SmRootSymbolNode(aToken);
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
- SmNode *pIndex = rNodeStack.Pop();
- SmNode *pBase = rNodeStack.Pop();
- pSNode->SetSubNodes(pIndex,pOper,pBase);
- rNodeStack.Push(pSNode);
-}
-
-void SmXMLSqrtContext_Impl::EndElement()
-{
- /*
- <msqrt> accepts any number of arguments; if this number is not 1, its
- contents are treated as a single "inferred <mrow>" containing its
- arguments
- */
- if (GetSmImport().GetNodeStack().Count() - nElementCount > 1)
- SmXMLRowContext_Impl::EndElement();
-
- SmToken aToken;
- aToken.cMathChar = MS_SQRT; //Temporary: alert, based on StarSymbol font
- aToken.nGroup = 0;
- aToken.nLevel = 0;
- aToken.eType = TSQRT;
- SmStructureNode *pSNode = new SmRootNode(aToken);
- SmNode *pOper = new SmRootSymbolNode(aToken);
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
- pSNode->SetSubNodes(0,pOper,rNodeStack.Pop());
- rNodeStack.Push(pSNode);
-}
-
-void SmXMLRowContext_Impl::EndElement()
-{
- SmNodeArray aRelationArray;
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
- ULONG nSize = rNodeStack.Count()-nElementCount;
-
- if (nSize > 0)
- {
- aRelationArray.resize(nSize);
- for (ULONG j=rNodeStack.Count()-nElementCount;j > 0;j--)
- aRelationArray[j-1] = rNodeStack.Pop();
-
-
- //If the first or last element is an operator with stretchyness
- //set then we must create a brace node here from those elements,
- //removing the stretchness from the operators and applying it to
- //ourselves, and creating the appropiate dummy StarMath none bracket
- //to balance the arrangement
- if (((aRelationArray[0]->GetScaleMode() == SCALE_HEIGHT)
- && (aRelationArray[0]->GetType() == NMATH))
- || ((aRelationArray[nSize-1]->GetScaleMode() == SCALE_HEIGHT)
- && (aRelationArray[nSize-1]->GetType() == NMATH)))
- {
- SmToken aToken;
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.nLevel = 5;
-
- int nLeft=0,nRight=0;
- if ((aRelationArray[0]->GetScaleMode() == SCALE_HEIGHT)
- && (aRelationArray[0]->GetType() == NMATH))
- {
- aToken = aRelationArray[0]->GetToken();
- nLeft=1;
- }
- else
- aToken.cMathChar = '\0';
-
- aToken.eType = TLPARENT;
- SmNode *pLeft = new SmMathSymbolNode(aToken);
-
- if ((aRelationArray[nSize-1]->GetScaleMode() == SCALE_HEIGHT)
- && (aRelationArray[nSize-1]->GetType() == NMATH))
- {
- aToken = aRelationArray[nSize-1]->GetToken();
- nRight=1;
- }
- else
- aToken.cMathChar = '\0';
-
- aToken.eType = TRPARENT;
- SmNode *pRight = new SmMathSymbolNode(aToken);
-
- SmNodeArray aRelationArray2;
-
- //!! nSize-nLeft-nRight may be < 0 !!
- int nRelArrSize = nSize-nLeft-nRight;
- if (nRelArrSize > 0)
- {
- aRelationArray2.resize(nRelArrSize);
- for (int i=0;i < nRelArrSize;i++)
- aRelationArray2[i] = aRelationArray[i+nLeft];
- }
-
- SmToken aDummy;
- SmStructureNode *pSNode = new SmBraceNode(aToken);
- SmStructureNode *pBody = new SmExpressionNode(aDummy);
- pBody->SetSubNodes(aRelationArray2);
-
- pSNode->SetSubNodes(pLeft,pBody,pRight);
- pSNode->SetScaleMode(SCALE_HEIGHT);
- rNodeStack.Push(pSNode);
- return;
- }
- }
- else //Multiple newlines result in empty row elements
- {
- aRelationArray.resize(1);
- SmToken aToken;
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.nLevel = 5;
- aToken.eType = TNEWLINE;
- aRelationArray[0] = new SmLineNode(aToken);
- }
-
- SmToken aDummy;
- SmStructureNode *pSNode = new SmExpressionNode(aDummy);
- pSNode->SetSubNodes(aRelationArray);
- rNodeStack.Push(pSNode);
-}
-
-
-SvXMLImportContext *SmXMLRowContext_Impl::StrictCreateChildContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference<xml::sax::XAttributeList>& xAttrList)
-{
- SvXMLImportContext* pContext = 0L;
-
- const SvXMLTokenMap& rTokenMap = GetSmImport().GetPresElemTokenMap();
- switch(rTokenMap.Get(nPrefix, rLocalName))
- {
- /*Note that these should accept malignmark subelements, but do not*/
- case XML_TOK_MN:
- pContext = GetSmImport().CreateNumberContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MI:
- pContext = GetSmImport().CreateIdentifierContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MO:
- pContext = GetSmImport().CreateOperatorContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MTEXT:
- pContext = GetSmImport().CreateTextContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MSPACE:
- pContext = GetSmImport().CreateSpaceContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MS:
- pContext = GetSmImport().CreateStringContext(nPrefix,rLocalName,
- xAttrList);
- break;
-
- /*Note: The maligngroup should only be seen when the row
- * (or decendants) are in a table*/
- case XML_TOK_MALIGNGROUP:
- pContext = GetSmImport().CreateAlignGroupContext(nPrefix,rLocalName,
- xAttrList);
- break;
-
- case XML_TOK_ANNOTATION:
- pContext = GetSmImport().CreateAnnotationContext(nPrefix,rLocalName,
- xAttrList);
- break;
-
- default:
- break;
- }
- return pContext;
-}
-
-
-SvXMLImportContext *SmXMLRowContext_Impl::CreateChildContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference<xml::sax::XAttributeList>& xAttrList)
-{
- SvXMLImportContext* pContext = StrictCreateChildContext(nPrefix,
- rLocalName, xAttrList);
-
- if (!pContext)
- {
- //Hmm, unrecognized for this level, check to see if its
- //an element that can have an implicit schema around it
- pContext = SmXMLDocContext_Impl::CreateChildContext(nPrefix,
- rLocalName,xAttrList);
- }
- return pContext;
-}
-
-
-SvXMLImportContext *SmXMLMultiScriptsContext_Impl::CreateChildContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference<xml::sax::XAttributeList>& xAttrList)
-{
- SvXMLImportContext* pContext = 0L;
-
- const SvXMLTokenMap& rTokenMap = GetSmImport().
- GetPresScriptEmptyElemTokenMap();
- switch(rTokenMap.Get(nPrefix, rLocalName))
- {
- case XML_TOK_MPRESCRIPTS:
- MiddleElement();
- pContext = GetSmImport().CreatePrescriptsContext(nPrefix,
- rLocalName, xAttrList);
- break;
- case XML_TOK_NONE:
- pContext = GetSmImport().CreateNoneContext(nPrefix,rLocalName,
- xAttrList);
- break;
- default:
- pContext = SmXMLRowContext_Impl::CreateChildContext(nPrefix,
- rLocalName,xAttrList);
- break;
- }
- return pContext;
-}
-
-void SmXMLMultiScriptsContext_Impl::MiddleElement()
-{
- bHasPrescripts=sal_True;
-
- DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount > 0,
- "Sub has no arguments");
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
- if (rNodeStack.Count()-nElementCount > 1)
- {
- SmToken aToken;
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.nLevel = 0;
- aToken.eType = TRSUB;
- ULONG nFinalCount = rNodeStack.Count()-nElementCount-1;
-
- SmNodeStack aReverseStack;
- while (rNodeStack.Count()-nElementCount)
- {
- SmNode *pThing = rNodeStack.Pop();
- aReverseStack.Push(pThing);
- }
-
- for (ULONG nCount=0;nCount < nFinalCount;nCount+=2)
- {
- SmSubSupNode *pNode = new SmSubSupNode(aToken);
-
- // initialize subnodes array
- SmNodeArray aSubNodes;
- aSubNodes.resize(1 + SUBSUP_NUM_ENTRIES);
- for (ULONG i = 1; i < aSubNodes.size(); i++)
- aSubNodes[i] = NULL;
-
- /*On each loop the base and its sub sup pair becomes the
- base for the next loop to which the next sub sup pair is
- attached, i.e. wheels within wheels*/
- //if (nCount == 0)
- aSubNodes[0] = aReverseStack.Pop();
-
- SmNode *pScriptNode = aReverseStack.Pop();
-
- if (pScriptNode && ((pScriptNode->GetToken().eType != TIDENT) ||
- (pScriptNode->GetToken().aText.Len())))
- aSubNodes[RSUB+1] = pScriptNode;
- pScriptNode = aReverseStack.Pop();
- if (pScriptNode && ((pScriptNode->GetToken().eType != TIDENT) ||
- (pScriptNode->GetToken().aText.Len())))
- aSubNodes[RSUP+1] = pScriptNode;
-
- pNode->SetSubNodes(aSubNodes);
- aReverseStack.Push(pNode);
- }
- rNodeStack.Push(aReverseStack.Pop());
- }
-}
-
-
-void SmXMLTableContext_Impl::EndElement()
-{
- SmNodeArray aExpressionArray;
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
- SmNodeStack aReverseStack;
- aExpressionArray.resize(rNodeStack.Count()-nElementCount);
-
- ULONG nRows = rNodeStack.Count()-nElementCount;
- USHORT nCols = 0;
-
- SmStructureNode *pArray;
- for (ULONG i=rNodeStack.Count()-nElementCount;i > 0;i--)
- {
- pArray = (SmStructureNode *)rNodeStack.Pop();
- if (pArray->GetNumSubNodes() == 0)
- {
- //This is a little tricky, it is possible that there was
- //be elements that were not inside a <mtd> pair, in which
- //case they will not be in a row, i.e. they will not have
- //SubNodes, so we have to wait until here before we can
- //resolve the situation. Implicitsurrounding tags are
- //surprisingly difficult to get right within this
- //architecture
-
- SmNodeArray aRelationArray;
- aRelationArray.resize(1);
- aRelationArray[0] = pArray;
- SmToken aDummy;
- pArray = new SmExpressionNode(aDummy);
- pArray->SetSubNodes(aRelationArray);
- }
-
- if (pArray->GetNumSubNodes() > nCols)
- nCols = pArray->GetNumSubNodes();
- aReverseStack.Push(pArray);
- }
- aExpressionArray.resize(nCols*nRows);
- ULONG j=0;
- while (aReverseStack.Count())
- {
- pArray = (SmStructureNode *)aReverseStack.Pop();
- for (USHORT i=0;i<pArray->GetNumSubNodes();i++)
- aExpressionArray[j++] = pArray->GetSubNode(i);
- }
-
- SmToken aToken;
- aToken.cMathChar = '\0';
- aToken.nGroup = TRGROUP;
- aToken.nLevel = 0;
- aToken.eType = TMATRIX;
- SmMatrixNode *pSNode = new SmMatrixNode(aToken);
- pSNode->SetSubNodes(aExpressionArray);
- pSNode->SetRowCol(static_cast<USHORT>(nRows),nCols);
- rNodeStack.Push(pSNode);
-}
-
-SvXMLImportContext *SmXMLTableRowContext_Impl::CreateChildContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference<xml::sax::XAttributeList>& xAttrList)
-{
- SvXMLImportContext* pContext = 0L;
-
- const SvXMLTokenMap& rTokenMap = GetSmImport().
- GetPresTableElemTokenMap();
- switch(rTokenMap.Get(nPrefix, rLocalName))
- {
- case XML_TOK_MTD:
- pContext = GetSmImport().CreateTableCellContext(nPrefix,
- rLocalName, xAttrList);
- break;
- default:
- pContext = SmXMLRowContext_Impl::CreateChildContext(nPrefix,
- rLocalName,xAttrList);
- break;
- }
- return pContext;
-}
-
-SvXMLImportContext *SmXMLTableContext_Impl::CreateChildContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference<xml::sax::XAttributeList>& xAttrList)
-{
- SvXMLImportContext* pContext = 0L;
-
- const SvXMLTokenMap& rTokenMap = GetSmImport().
- GetPresTableElemTokenMap();
- switch(rTokenMap.Get(nPrefix, rLocalName))
- {
- case XML_TOK_MTR:
- pContext = GetSmImport().CreateTableRowContext(nPrefix,rLocalName,
- xAttrList);
- break;
- default:
- pContext = SmXMLTableRowContext_Impl::CreateChildContext(nPrefix,
- rLocalName,xAttrList);
- break;
- }
- return pContext;
-}
-
-void SmXMLMultiScriptsContext_Impl::EndElement()
-{
- if (!bHasPrescripts)
- MiddleElement();
-
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
- if (rNodeStack.Count()-nElementCount > 1)
- {
- SmToken aToken;
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.nLevel = 0;
- aToken.eType = TLSUB;
- ULONG nFinalCount = rNodeStack.Count()-nElementCount-1;
-
- SmNodeStack aReverseStack;
- while (rNodeStack.Count()-nElementCount)
- aReverseStack.Push(rNodeStack.Pop());
- for (ULONG nCount=0;nCount < nFinalCount;nCount+=2)
- {
- SmSubSupNode *pNode = new SmSubSupNode(aToken);
-
- // initialize subnodes array
- SmNodeArray aSubNodes;
- aSubNodes.resize(1 + SUBSUP_NUM_ENTRIES);
- for (ULONG i = 1; i < aSubNodes.size(); i++)
- aSubNodes[i] = NULL;
-
- /*On each loop the base and its sub sup pair becomes the
- base for the next loop to which the next sub sup pair is
- attached, i.e. wheels within wheels*/
- //if (nCount == 0)
- aSubNodes[0] = aReverseStack.Pop();
-
- SmNode *pScriptNode = aReverseStack.Pop();
- if (pScriptNode->GetToken().aText.Len())
- aSubNodes[LSUB+1] = pScriptNode;
- pScriptNode = aReverseStack.Pop();
- if (pScriptNode->GetToken().aText.Len())
- aSubNodes[LSUP+1] = pScriptNode;
-
- pNode->SetSubNodes(aSubNodes);
- aReverseStack.Push(pNode);
- }
- rNodeStack.Push(aReverseStack.Pop());
- }
-
-}
-void SmXMLActionContext_Impl::EndElement()
-{
- /*For now we will just assume that the
- selected attribute is one, and then just display
- that expression alone, i.e. remove all expect the
- first pushed one*/
-
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
- for (ULONG i=rNodeStack.Count()-nElementCount;i > 1;i--)
- {
- delete rNodeStack.Pop();
- }
-}
-
-SvXMLImportContext *SmXMLImport::CreateContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- if ( XML_NAMESPACE_OFFICE == nPrefix )
- {
- if ( (IsXMLToken(rLocalName, XML_DOCUMENT) ||
- IsXMLToken(rLocalName, XML_DOCUMENT_META)))
- {
- uno::Reference<xml::sax::XDocumentHandler> xDocBuilder(
- mxServiceFactory->createInstance(
- ::rtl::OUString::createFromAscii(
- "com.sun.star.xml.dom.SAXDocumentBuilder")),
- uno::UNO_QUERY_THROW);
- uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
- GetModel(), uno::UNO_QUERY_THROW);
- return IsXMLToken(rLocalName, XML_DOCUMENT_META)
- ? new SvXMLMetaDocumentContext(*this,
- XML_NAMESPACE_OFFICE, rLocalName,
- xDPS->getDocumentProperties(), xDocBuilder)
- // flat OpenDocument file format -- this has not been tested...
- : new SmXMLFlatDocContext_Impl( *this, nPrefix, rLocalName,
- xDPS->getDocumentProperties(), xDocBuilder);
- }
- else
- {
- return new SmXMLOfficeContext_Impl( *this,nPrefix,rLocalName);
- }
- }
- else
- return new SmXMLDocContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateRowContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLRowContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateTextContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLTextContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateAnnotationContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLAnnotationContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateStringContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLStringContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateNumberContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLNumberContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateIdentifierContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLIdentifierContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateOperatorContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLOperatorContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateSpaceContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLSpaceContext_Impl(*this,nPrefix,rLocalName);
-}
-
-
-SvXMLImportContext *SmXMLImport::CreateFracContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLFracContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateSqrtContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLSqrtContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateRootContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLRootContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateStyleContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLStyleContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreatePaddedContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLPaddedContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreatePhantomContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLPhantomContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateFencedContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLFencedContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateErrorContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLErrorContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateSubContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLSubContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateSubSupContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLSubSupContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateSupContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLSupContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateUnderContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLUnderContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateOverContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLOverContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateUnderOverContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLUnderOverContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateMultiScriptsContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLMultiScriptsContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateTableContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLTableContext_Impl(*this,nPrefix,rLocalName);
-}
-SvXMLImportContext *SmXMLImport::CreateTableRowContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLTableRowContext_Impl(*this,nPrefix,rLocalName);
-}
-SvXMLImportContext *SmXMLImport::CreateTableCellContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLTableCellContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateNoneContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLNoneContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreatePrescriptsContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLPrescriptsContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateAlignGroupContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLAlignGroupContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateActionContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLActionContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SmXMLImport::~SmXMLImport() throw ()
-{
- delete pPresLayoutElemTokenMap;
- delete pPresElemTokenMap;
- delete pPresScriptEmptyElemTokenMap;
- delete pPresTableElemTokenMap;
- delete pPresLayoutAttrTokenMap;
- delete pFencedAttrTokenMap;
- delete pColorTokenMap;
- delete pOperatorAttrTokenMap;
- delete pAnnotationAttrTokenMap;
-}
-
-void SmXMLImport::SetViewSettings(const Sequence<PropertyValue>& aViewProps)
-{
- uno::Reference <frame::XModel> xModel = GetModel();
- if ( !xModel.is() )
- return;
-
- uno::Reference <lang::XUnoTunnel> xTunnel;
- xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY);
- SmModel *pModel = reinterpret_cast<SmModel *>
- (xTunnel->getSomething(SmModel::getUnoTunnelId()));
-
- if ( !pModel )
- return;
-
- SmDocShell *pDocShell =
- static_cast<SmDocShell*>(pModel->GetObjectShell());
- if ( !pDocShell )
- return;
-
- Rectangle aRect( pDocShell->GetVisArea() );
-
- sal_Int32 nCount = aViewProps.getLength();
- const PropertyValue *pValue = aViewProps.getConstArray();
-
- long nTmp = 0;
- //sal_Bool bShowDeletes = sal_False, bShowInserts = sal_False, bShowFooter = sal_False, bShowHeader = sal_False;
-
- for (sal_Int32 i = 0; i < nCount ; i++)
- {
- if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ViewAreaTop" ) ) )
- {
- pValue->Value >>= nTmp;
- aRect.setY( nTmp );
- }
- else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ViewAreaLeft" ) ) )
- {
- pValue->Value >>= nTmp;
- aRect.setX( nTmp );
- }
- else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ViewAreaWidth" ) ) )
- {
- pValue->Value >>= nTmp;
- Size aSize( aRect.GetSize() );
- aSize.Width() = nTmp;
- aRect.SetSize( aSize );
- }
- else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ViewAreaHeight" ) ) )
- {
- pValue->Value >>= nTmp;
- Size aSize( aRect.GetSize() );
- aSize.Height() = nTmp;
- aRect.SetSize( aSize );
- }
- pValue++;
- }
-
- pDocShell->SetVisArea ( aRect );
-}
-
-void SmXMLImport::SetConfigurationSettings(const Sequence<PropertyValue>& aConfProps)
-{
- uno::Reference < XPropertySet > xProps ( GetModel(), UNO_QUERY );
- if ( xProps.is() )
- {
- Reference < XPropertySetInfo > xInfo ( xProps->getPropertySetInfo() );
- if (xInfo.is() )
- {
- sal_Int32 nCount = aConfProps.getLength();
- const PropertyValue* pValues = aConfProps.getConstArray();
-
- const OUString sFormula ( RTL_CONSTASCII_USTRINGPARAM ( "Formula" ) );
- const OUString sBasicLibraries ( RTL_CONSTASCII_USTRINGPARAM ( "BasicLibraries" ) );
- const OUString sDialogLibraries ( RTL_CONSTASCII_USTRINGPARAM ( "DialogLibraries" ) );
- while ( nCount-- )
- {
- if (pValues->Name != sFormula &&
- pValues->Name != sBasicLibraries &&
- pValues->Name != sDialogLibraries)
- {
- try
- {
- if ( xInfo->hasPropertyByName( pValues->Name ) )
- xProps->setPropertyValue( pValues->Name, pValues->Value );
- }
- catch( Exception& )
- {
- DBG_ERROR( "SmXMLImport::SetConfigurationSettings: Exception!" );
- }
- }
-
- pValues++;
- }
- }
- }
-}
-
-
-////////////////////////////////////////////////////////////
-
+/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_starmath.hxx" + +/*todo: Change characters and tcharacters to accumulate the characters together +into one string, xml parser hands them to us line by line rather than all in +one go*/ + +#include <com/sun/star/xml/sax/XErrorHandler.hpp> +#include <com/sun/star/xml/sax/XEntityResolver.hpp> +#include <com/sun/star/xml/sax/InputSource.hpp> +#include <com/sun/star/xml/sax/XDTDHandler.hpp> +#include <com/sun/star/xml/sax/XParser.hpp> +#include <com/sun/star/io/XActiveDataSource.hpp> +#include <com/sun/star/io/XActiveDataControl.hpp> +#include <com/sun/star/document/XDocumentProperties.hpp> +#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> +#include <com/sun/star/packages/zip/ZipIOException.hpp> +#include <com/sun/star/task/XStatusIndicatorFactory.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/embed/ElementModes.hpp> +#include <com/sun/star/uno/Any.h> + +#include <rtl/math.hxx> +#include <sfx2/frame.hxx> +#include <sfx2/docfile.hxx> +#include <tools/debug.hxx> +#include <tools/urlobj.hxx> +#include <svtools/sfxecode.hxx> +#include <unotools/saveopt.hxx> +#include <svl/stritem.hxx> +#include <svl/itemprop.hxx> +#include <unotools/processfactory.hxx> +#include <unotools/streamwrap.hxx> +#include <xmloff/xmlnmspe.hxx> +#include <xmloff/xmltoken.hxx> +#include <xmloff/nmspmap.hxx> +#include <xmloff/attrlist.hxx> +#include <xmloff/xmluconv.hxx> +#include <xmloff/xmlmetai.hxx> +#include <osl/mutex.hxx> +#include <comphelper/genericpropertyset.hxx> + +#include <memory> + +#include "mathmlimport.hxx" +#include "mathtype.hxx" +#include <starmath.hrc> +#include <unomodel.hxx> +#include <document.hxx> +#include <utility.hxx> + +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::document; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star; +using namespace ::xmloff::token; + +using ::rtl::OUString; +using ::rtl::OUStringBuffer; + +#define IMPORT_SVC_NAME RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.XMLImportFilter") + +#undef WANTEXCEPT + +//////////////////////////////////////////////////////////// + +ULONG SmXMLImportWrapper::Import(SfxMedium &rMedium) +{ + ULONG nError = ERRCODE_SFX_DOLOADFAILED; + + uno::Reference<lang::XMultiServiceFactory> xServiceFactory( + utl::getProcessServiceFactory()); + DBG_ASSERT(xServiceFactory.is(), "XMLReader::Read: got no service manager"); + if ( !xServiceFactory.is() ) + return nError; + + //Make a model component from our SmModel + uno::Reference< lang::XComponent > xModelComp( xModel, uno::UNO_QUERY ); + DBG_ASSERT( xModelComp.is(), "XMLReader::Read: got no model" ); + + // try to get an XStatusIndicator from the Medium + uno::Reference<task::XStatusIndicator> xStatusIndicator; + + sal_Bool bEmbedded = sal_False; + uno::Reference <lang::XUnoTunnel> xTunnel; + xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY); + SmModel *pModel = reinterpret_cast<SmModel *> + (xTunnel->getSomething(SmModel::getUnoTunnelId())); + + SmDocShell *pDocShell = pModel ? + static_cast<SmDocShell*>(pModel->GetObjectShell()) : 0; + if (pDocShell) + { +// if (pDocShell->GetMedium()) + { + DBG_ASSERT( pDocShell->GetMedium() == &rMedium, + "different SfxMedium found" ); + + SfxItemSet* pSet = rMedium.GetItemSet(); + if (pSet) + { + const SfxUnoAnyItem* pItem = static_cast<const SfxUnoAnyItem*>( + pSet->GetItem(SID_PROGRESS_STATUSBAR_CONTROL) ); + if (pItem) + pItem->GetValue() >>= xStatusIndicator; + } + } + + if ( SFX_CREATE_MODE_EMBEDDED == pDocShell->GetCreateMode() ) + bEmbedded = sal_True; + } + + comphelper::PropertyMapEntry aInfoMap[] = + { + { "PrivateData", sizeof("PrivateData")-1, 0, + &::getCppuType( (Reference<XInterface> *)0 ), + beans::PropertyAttribute::MAYBEVOID, 0 }, + { "BaseURI", sizeof("BaseURI")-1, 0, + &::getCppuType( (OUString *)0 ), + beans::PropertyAttribute::MAYBEVOID, 0 }, + { "StreamRelPath", sizeof("StreamRelPath")-1, 0, + &::getCppuType( (OUString *)0 ), + beans::PropertyAttribute::MAYBEVOID, 0 }, + { "StreamName", sizeof("StreamName")-1, 0, + &::getCppuType( (OUString *)0 ), + beans::PropertyAttribute::MAYBEVOID, 0 }, + { NULL, 0, 0, NULL, 0, 0 } + }; + uno::Reference< beans::XPropertySet > xInfoSet( + comphelper::GenericPropertySet_CreateInstance( + new comphelper::PropertySetInfo( aInfoMap ) ) ); + + // Set base URI + OUString sPropName( RTL_CONSTASCII_USTRINGPARAM("BaseURI") ); + xInfoSet->setPropertyValue( sPropName, makeAny( rMedium.GetBaseURL() ) ); + + sal_Int32 nSteps=3; + if ( !(rMedium.IsStorage())) + nSteps = 1; + + sal_Int32 nProgressRange(nSteps); + if (xStatusIndicator.is()) + { + xStatusIndicator->start(String(SmResId(STR_STATSTR_READING)), + nProgressRange); + } + + nSteps=0; + if (xStatusIndicator.is()) + xStatusIndicator->setValue(nSteps++); + + if ( rMedium.IsStorage()) + { + // TODO/LATER: handle the case of embedded links gracefully + if ( bEmbedded ) // && !rMedium.GetStorage()->IsRoot() ) + { + OUString aName( RTL_CONSTASCII_USTRINGPARAM( "dummyObjName" ) ); + if ( rMedium.GetItemSet() ) + { + const SfxStringItem* pDocHierarchItem = static_cast<const SfxStringItem*>( + rMedium.GetItemSet()->GetItem(SID_DOC_HIERARCHICALNAME) ); + if ( pDocHierarchItem ) + aName = pDocHierarchItem->GetValue(); + } + + if ( aName.getLength() ) + { + sPropName = OUString(RTL_CONSTASCII_USTRINGPARAM("StreamRelPath")); + xInfoSet->setPropertyValue( sPropName, makeAny( aName ) ); + } + } + + sal_Bool bOASIS = ( SotStorage::GetVersion( rMedium.GetStorage() ) > SOFFICE_FILEFORMAT_60 ); + if (xStatusIndicator.is()) + xStatusIndicator->setValue(nSteps++); + + ULONG nWarn = ReadThroughComponent( + rMedium.GetStorage(), xModelComp, "meta.xml", "Meta.xml", + xServiceFactory, xInfoSet, + (bOASIS ? "com.sun.star.comp.Math.XMLOasisMetaImporter" + : "com.sun.star.comp.Math.XMLMetaImporter") ); + + if ( nWarn != ERRCODE_IO_BROKENPACKAGE ) + { + if (xStatusIndicator.is()) + xStatusIndicator->setValue(nSteps++); + + nWarn = ReadThroughComponent( + rMedium.GetStorage(), xModelComp, "settings.xml", 0, + xServiceFactory, xInfoSet, + (bOASIS ? "com.sun.star.comp.Math.XMLOasisSettingsImporter" + : "com.sun.star.comp.Math.XMLSettingsImporter" ) ); + + if ( nWarn != ERRCODE_IO_BROKENPACKAGE ) + { + if (xStatusIndicator.is()) + xStatusIndicator->setValue(nSteps++); + + nError = ReadThroughComponent( + rMedium.GetStorage(), xModelComp, "content.xml", "Content.xml", + xServiceFactory, xInfoSet, "com.sun.star.comp.Math.XMLImporter" ); + } + else + nError = ERRCODE_IO_BROKENPACKAGE; + } + else + nError = ERRCODE_IO_BROKENPACKAGE; + } + else + { + Reference<io::XInputStream> xInputStream = + new utl::OInputStreamWrapper(rMedium.GetInStream()); + + if (xStatusIndicator.is()) + xStatusIndicator->setValue(nSteps++); + + nError = ReadThroughComponent( xInputStream, xModelComp, + xServiceFactory, xInfoSet, "com.sun.star.comp.Math.XMLImporter", FALSE ); + } + + if (xStatusIndicator.is()) + xStatusIndicator->end(); + return nError; +} + + +/// read a component (file + filter version) +ULONG SmXMLImportWrapper::ReadThroughComponent( + Reference<io::XInputStream> xInputStream, + Reference<XComponent> xModelComponent, + Reference<lang::XMultiServiceFactory> & rFactory, + Reference<beans::XPropertySet> & rPropSet, + const sal_Char* pFilterName, + sal_Bool bEncrypted ) +{ + ULONG nError = ERRCODE_SFX_DOLOADFAILED; + DBG_ASSERT(xInputStream.is(), "input stream missing"); + DBG_ASSERT(xModelComponent.is(), "document missing"); + DBG_ASSERT(rFactory.is(), "factory missing"); + DBG_ASSERT(NULL != pFilterName,"I need a service name for the component!"); + + // prepare ParserInputSrouce + xml::sax::InputSource aParserInput; + aParserInput.aInputStream = xInputStream; + + // get parser + Reference< xml::sax::XParser > xParser( + rFactory->createInstance( + OUString::createFromAscii("com.sun.star.xml.sax.Parser") ), + UNO_QUERY ); + DBG_ASSERT( xParser.is(), "Can't create parser" ); + if ( !xParser.is() ) + return nError; + + Sequence<Any> aArgs( 1 ); + aArgs[0] <<= rPropSet; + + // get filter + Reference< xml::sax::XDocumentHandler > xFilter( + rFactory->createInstanceWithArguments( + OUString::createFromAscii(pFilterName), aArgs ), + UNO_QUERY ); + DBG_ASSERT( xFilter.is(), "Can't instantiate filter component." ); + if ( !xFilter.is() ) + return nError; + + // connect parser and filter + xParser->setDocumentHandler( xFilter ); + + // connect model and filter + Reference < XImporter > xImporter( xFilter, UNO_QUERY ); + xImporter->setTargetDocument( xModelComponent ); + + // finally, parser the stream + try + { + xParser->parseStream( aParserInput ); + + uno::Reference<lang::XUnoTunnel> xFilterTunnel; + xFilterTunnel = uno::Reference<lang::XUnoTunnel> + ( xFilter, uno::UNO_QUERY ); + SmXMLImport *pFilter = reinterpret_cast< SmXMLImport * >( + sal::static_int_cast< sal_uIntPtr >( + xFilterTunnel->getSomething( SmXMLImport::getUnoTunnelId() ))); + if ( pFilter && pFilter->GetSuccess() ) + nError = 0; + } + catch( xml::sax::SAXParseException& r ) + { + // sax parser sends wrapped exceptions, + // try to find the original one + xml::sax::SAXException aSaxEx = *(xml::sax::SAXException*)(&r); + sal_Bool bTryChild = sal_True; + + while( bTryChild ) + { + xml::sax::SAXException aTmp; + if ( aSaxEx.WrappedException >>= aTmp ) + aSaxEx = aTmp; + else + bTryChild = sal_False; + } + + packages::zip::ZipIOException aBrokenPackage; + if ( aSaxEx.WrappedException >>= aBrokenPackage ) + return ERRCODE_IO_BROKENPACKAGE; + + if ( bEncrypted ) + nError = ERRCODE_SFX_WRONGPASSWORD; + } + catch( xml::sax::SAXException& r ) + { + packages::zip::ZipIOException aBrokenPackage; + if ( r.WrappedException >>= aBrokenPackage ) + return ERRCODE_IO_BROKENPACKAGE; + + if ( bEncrypted ) + nError = ERRCODE_SFX_WRONGPASSWORD; + } + catch( packages::zip::ZipIOException& ) + { + nError = ERRCODE_IO_BROKENPACKAGE; + } + catch( io::IOException& ) + { + } + + return nError; +} + + +ULONG SmXMLImportWrapper::ReadThroughComponent( + const uno::Reference< embed::XStorage >& xStorage, + Reference<XComponent> xModelComponent, + const sal_Char* pStreamName, + const sal_Char* pCompatibilityStreamName, + Reference<lang::XMultiServiceFactory> & rFactory, + Reference<beans::XPropertySet> & rPropSet, + const sal_Char* pFilterName ) +{ + DBG_ASSERT(xStorage.is(), "Need storage!"); + DBG_ASSERT(NULL != pStreamName, "Please, please, give me a name!"); + + // open stream (and set parser input) + OUString sStreamName = OUString::createFromAscii(pStreamName); + uno::Reference < container::XNameAccess > xAccess( xStorage, uno::UNO_QUERY ); + if ( !xAccess->hasByName(sStreamName) || !xStorage->isStreamElement(sStreamName) ) + { + // stream name not found! Then try the compatibility name. + // do we even have an alternative name? + if ( pCompatibilityStreamName ) + sStreamName = OUString::createFromAscii(pCompatibilityStreamName); + } + + // get input stream + try + { + uno::Reference < io::XStream > xEventsStream = xStorage->openStreamElement( sStreamName, embed::ElementModes::READ ); + + // determine if stream is encrypted or not + uno::Reference < beans::XPropertySet > xProps( xEventsStream, uno::UNO_QUERY ); + Any aAny = xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Encrypted") ) ); + sal_Bool bEncrypted = sal_False; + if ( aAny.getValueType() == ::getBooleanCppuType() ) + aAny >>= bEncrypted; + + // set Base URL + if ( rPropSet.is() ) + { + OUString sPropName( RTL_CONSTASCII_USTRINGPARAM("StreamName") ); + rPropSet->setPropertyValue( sPropName, makeAny( sStreamName ) ); + } + + + Reference < io::XInputStream > xStream = xEventsStream->getInputStream(); + return ReadThroughComponent( xStream, xModelComponent, rFactory, rPropSet, pFilterName, bEncrypted ); + } + catch ( packages::WrongPasswordException& ) + { + return ERRCODE_SFX_WRONGPASSWORD; + } + catch( packages::zip::ZipIOException& ) + { + return ERRCODE_IO_BROKENPACKAGE; + } + catch ( uno::Exception& ) + { + } + + return ERRCODE_SFX_DOLOADFAILED; +} + +//////////////////////////////////////////////////////////// + +SmXMLImport::SmXMLImport( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory, + sal_uInt16 nImportFlags) +: SvXMLImport( xServiceFactory, nImportFlags ), + pPresLayoutElemTokenMap(0), + pPresLayoutAttrTokenMap(0), + pFencedAttrTokenMap(0), + pOperatorAttrTokenMap(0), + pAnnotationAttrTokenMap(0), + pPresElemTokenMap(0), + pPresScriptEmptyElemTokenMap(0), + pPresTableElemTokenMap(0), + pColorTokenMap(0), + bSuccess(sal_False) +{ +} + +const uno::Sequence< sal_Int8 > & SmXMLImport::getUnoTunnelId() throw() +{ + static uno::Sequence< sal_Int8 > * pSeq = 0; + if ( !pSeq ) + { + osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); + if ( !pSeq ) + { + static uno::Sequence< sal_Int8 > aSeq( 16 ); + rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True ); + pSeq = &aSeq; + } + } + return *pSeq; +} + +OUString SAL_CALL SmXMLImport_getImplementationName() throw() +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLImporter" ) ); +} + +uno::Sequence< OUString > SAL_CALL SmXMLImport_getSupportedServiceNames() + throw() +{ + const OUString aServiceName( IMPORT_SVC_NAME ); + const uno::Sequence< OUString > aSeq( &aServiceName, 1 ); + return aSeq; +} + +uno::Reference< uno::XInterface > SAL_CALL SmXMLImport_createInstance( + const uno::Reference< lang::XMultiServiceFactory > & rSMgr) + throw( uno::Exception ) +{ + // #110680# + // return (cppu::OWeakObject*)new SmXMLImport(IMPORT_ALL); + return (cppu::OWeakObject*)new SmXMLImport(rSMgr, IMPORT_ALL); +} + +//////////////////////////////////////////////////////////// + +OUString SAL_CALL SmXMLImportMeta_getImplementationName() throw() +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLOasisMetaImporter" ) ); +} + +uno::Sequence< OUString > SAL_CALL SmXMLImportMeta_getSupportedServiceNames() +throw() +{ + const OUString aServiceName( IMPORT_SVC_NAME ); + const uno::Sequence< OUString > aSeq( &aServiceName, 1 ); + return aSeq; +} + +uno::Reference< uno::XInterface > SAL_CALL SmXMLImportMeta_createInstance( + const uno::Reference< lang::XMultiServiceFactory > & rSMgr) +throw( uno::Exception ) +{ + // #110680# + // return (cppu::OWeakObject*)new SmXMLImport( IMPORT_META ); + return (cppu::OWeakObject*)new SmXMLImport( rSMgr, IMPORT_META ); +} + +//////////////////////////////////////////////////////////// + +OUString SAL_CALL SmXMLImportSettings_getImplementationName() throw() +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLOasisSettingsImporter" ) ); +} + +uno::Sequence< OUString > SAL_CALL SmXMLImportSettings_getSupportedServiceNames() + throw() +{ + const OUString aServiceName( IMPORT_SVC_NAME ); + const uno::Sequence< OUString > aSeq( &aServiceName, 1 ); + return aSeq; +} + +uno::Reference< uno::XInterface > SAL_CALL SmXMLImportSettings_createInstance( + const uno::Reference< lang::XMultiServiceFactory > & rSMgr) + throw( uno::Exception ) +{ + // #110680# + // return (cppu::OWeakObject*)new SmXMLImport( IMPORT_SETTINGS ); + return (cppu::OWeakObject*)new SmXMLImport( rSMgr, IMPORT_SETTINGS ); +} + +//////////////////////////////////////////////////////////// + +// XServiceInfo +// override empty method from parent class +rtl::OUString SAL_CALL SmXMLImport::getImplementationName() + throw(uno::RuntimeException) +{ + OUString aTxt; + switch( getImportFlags() ) + { + case IMPORT_META: + aTxt = SmXMLImportMeta_getImplementationName(); + break; + case IMPORT_SETTINGS: + aTxt = SmXMLImportSettings_getImplementationName(); + break; + case IMPORT_ALL: + default: + aTxt = SmXMLImport_getImplementationName(); + break; + } + return aTxt; +} + + +sal_Int64 SAL_CALL SmXMLImport::getSomething( + const uno::Sequence< sal_Int8 >&rId ) +throw(uno::RuntimeException) +{ + if ( rId.getLength() == 16 && + 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), + rId.getConstArray(), 16 ) ) + return sal::static_int_cast< sal_Int64 >(reinterpret_cast< sal_uIntPtr >(this)); + + return SvXMLImport::getSomething( rId ); +} + +void SmXMLImport::endDocument(void) + throw(xml::sax::SAXException, uno::RuntimeException) +{ + //Set the resulted tree into the SmDocShell where it belongs + SmNode *pTree; + if (NULL != (pTree = GetTree())) + { + uno::Reference <frame::XModel> xModel = GetModel(); + uno::Reference <lang::XUnoTunnel> xTunnel; + xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY); + SmModel *pModel = reinterpret_cast<SmModel *> + (xTunnel->getSomething(SmModel::getUnoTunnelId())); + + if (pModel) + { + SmDocShell *pDocShell = + static_cast<SmDocShell*>(pModel->GetObjectShell()); + pDocShell->SetFormulaTree(pTree); + if (0 == aText.Len()) //If we picked up no annotation text + { + //Make up some editable text + aText = pDocShell->GetText(); + pTree->CreateTextFromNode(aText); + aText.EraseTrailingChars(); + if ((aText.GetChar(0) == '{') && + (aText.GetChar(aText.Len()-1) == '}')) + { + aText.Erase(0,1); + aText.Erase(aText.Len()-1,1); + } + } + pDocShell->SetText( String() ); + + // Convert symbol names + SmParser &rParser = pDocShell->GetParser(); + BOOL bVal = rParser.IsImportSymbolNames(); + rParser.SetImportSymbolNames( TRUE ); + SmNode *pTmpTree = rParser.Parse( aText ); + aText = rParser.GetText(); + delete pTmpTree; + rParser.SetImportSymbolNames( bVal ); + + pDocShell->SetText( aText ); + } + DBG_ASSERT(pModel,"So there *was* a uno problem after all"); + + bSuccess = sal_True; + } + + SvXMLImport::endDocument(); +} + +//////////////////////////////////////////////////////////// + +class SmXMLImportContext: public SvXMLImportContext +{ +public: + SmXMLImportContext( SmXMLImport &rImport, sal_uInt16 nPrfx, + const OUString& rLName) + : SvXMLImportContext(rImport, nPrfx, rLName) {} + + const SmXMLImport& GetSmImport() const + { + return (const SmXMLImport&)GetImport(); + } + + SmXMLImport& GetSmImport() + { + return (SmXMLImport&)GetImport(); + } + + virtual void TCharacters(const OUString & /*rChars*/); + virtual void Characters(const OUString &rChars); + virtual SvXMLImportContext *CreateChildContext(sal_uInt16 /*nPrefix*/, const OUString& /*rLocalName*/, const uno::Reference< xml::sax::XAttributeList > & /*xAttrList*/); +}; + +void SmXMLImportContext::TCharacters(const OUString & /*rChars*/) +{ +} + +void SmXMLImportContext::Characters(const OUString &rChars) +{ + /* + Whitespace occurring within the content of token elements is "trimmed" + from the ends (i.e. all whitespace at the beginning and end of the + content is removed), and "collapsed" internally (i.e. each sequence of + 1 or more whitespace characters is replaced with one blank character). + */ + //collapsing not done yet! + const OUString &rChars2 = rChars.trim(); + if (rChars2.getLength()) + TCharacters(rChars2/*.collapse()*/); +} + +SvXMLImportContext * SmXMLImportContext::CreateChildContext(sal_uInt16 /*nPrefix*/, + const OUString& /*rLocalName*/, + const uno::Reference< xml::sax::XAttributeList > & /*xAttrList*/) +{ + return 0; +} + +//////////////////////////////////////////////////////////// + +struct SmXMLContext_Helper +{ + sal_Int8 nIsBold; + sal_Int8 nIsItalic; + double nFontSize; + sal_Bool bFontNodeNeeded; + OUString sFontFamily; + OUString sColor; + + SmXMLImportContext rContext; + + SmXMLContext_Helper(SmXMLImportContext &rImport) : + nIsBold(-1), nIsItalic(-1), nFontSize(0.0), rContext(rImport) {} + + void RetrieveAttrs(const uno::Reference< xml::sax::XAttributeList > &xAttrList ); + void ApplyAttrs(); +}; + +void SmXMLContext_Helper::RetrieveAttrs(const uno::Reference< + xml::sax::XAttributeList > & xAttrList ) +{ + sal_Int8 nOldIsBold=nIsBold; + sal_Int8 nOldIsItalic=nIsItalic; + double nOldFontSize=nFontSize; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + OUString sOldFontFamily = sFontFamily; + for (sal_Int16 i=0;i<nAttrCount;i++) + { + OUString sAttrName = xAttrList->getNameByIndex(i); + OUString aLocalName; + sal_uInt16 nPrefix = rContext.GetSmImport().GetNamespaceMap(). + GetKeyByAttrName(sAttrName,&aLocalName); + OUString sValue = xAttrList->getValueByIndex(i); + const SvXMLTokenMap &rAttrTokenMap = + rContext.GetSmImport().GetPresLayoutAttrTokenMap(); + switch(rAttrTokenMap.Get(nPrefix,aLocalName)) + { + case XML_TOK_FONTWEIGHT: + nIsBold = sValue.equals(GetXMLToken(XML_BOLD)); + break; + case XML_TOK_FONTSTYLE: + nIsItalic = sValue.equals(GetXMLToken(XML_ITALIC)); + break; + case XML_TOK_FONTSIZE: + SvXMLUnitConverter::convertDouble(nFontSize,sValue); + rContext.GetSmImport().GetMM100UnitConverter(). + setXMLMeasureUnit(MAP_POINT); + if (-1 == sValue.indexOf(GetXMLToken(XML_UNIT_PT))) + { + if (-1 == sValue.indexOf('%')) + nFontSize=0.0; + else + { + rContext.GetSmImport().GetMM100UnitConverter(). + setXMLMeasureUnit(MAP_RELATIVE); + } + } + break; + case XML_TOK_FONTFAMILY: + sFontFamily = sValue; + break; + case XML_TOK_COLOR: + sColor = sValue; + break; + default: + break; + } + } + + if ((nOldIsBold!=nIsBold) || (nOldIsItalic!=nIsItalic) || + (nOldFontSize!=nFontSize) || (sOldFontFamily!=sFontFamily) + || sColor.getLength()) + bFontNodeNeeded=sal_True; + else + bFontNodeNeeded=sal_False; +} + +void SmXMLContext_Helper::ApplyAttrs() +{ + SmNodeStack &rNodeStack = rContext.GetSmImport().GetNodeStack(); + + if (bFontNodeNeeded) + { + SmToken aToken; + aToken.cMathChar = '\0'; + aToken.nGroup = 0; + aToken.nLevel = 5; + + if (nIsBold != -1) + { + if (nIsBold) + aToken.eType = TBOLD; + else + aToken.eType = TNBOLD; + SmStructureNode *pFontNode = static_cast<SmStructureNode *> + (new SmFontNode(aToken)); + pFontNode->SetSubNodes(0,rNodeStack.Pop()); + rNodeStack.Push(pFontNode); + } + if (nIsItalic != -1) + { + if (nIsItalic) + aToken.eType = TITALIC; + else + aToken.eType = TNITALIC; + SmStructureNode *pFontNode = static_cast<SmStructureNode *> + (new SmFontNode(aToken)); + pFontNode->SetSubNodes(0,rNodeStack.Pop()); + rNodeStack.Push(pFontNode); + } + if (nFontSize != 0.0) + { + aToken.eType = TSIZE; + SmFontNode *pFontNode = new SmFontNode(aToken); + + if (MAP_RELATIVE == rContext.GetSmImport().GetMM100UnitConverter(). + getXMLMeasureUnit()) + { + if (nFontSize < 100.00) + pFontNode->SetSizeParameter(Fraction(100.00/nFontSize), + FNTSIZ_DIVIDE); + else + pFontNode->SetSizeParameter(Fraction(nFontSize/100.00), + FNTSIZ_MULTIPLY); + } + else + pFontNode->SetSizeParameter(Fraction(nFontSize),FNTSIZ_ABSOLUT); + + pFontNode->SetSubNodes(0,rNodeStack.Pop()); + rNodeStack.Push(pFontNode); + } + if (sFontFamily.getLength()) + { + if (sFontFamily.equalsIgnoreAsciiCase(GetXMLToken(XML_FIXED))) + aToken.eType = TFIXED; + else if (sFontFamily.equalsIgnoreAsciiCase(OUString( + RTL_CONSTASCII_USTRINGPARAM("sans")))) + aToken.eType = TSANS; + else if (sFontFamily.equalsIgnoreAsciiCase(OUString( + RTL_CONSTASCII_USTRINGPARAM("serif")))) + aToken.eType = TSERIF; + else //Just give up, we need to extend our font mechanism to be + //more general + return; + + aToken.aText = sFontFamily; + SmFontNode *pFontNode = new SmFontNode(aToken); + pFontNode->SetSubNodes(0,rNodeStack.Pop()); + rNodeStack.Push(pFontNode); + } + if (sColor.getLength()) + { + //Again we can only handle a small set of colours in + //StarMath for now. + const SvXMLTokenMap& rTokenMap = + rContext.GetSmImport().GetColorTokenMap(); + aToken.eType = static_cast<SmTokenType>(rTokenMap.Get( + XML_NAMESPACE_MATH, sColor)); + if (aToken.eType != -1) + { + SmFontNode *pFontNode = new SmFontNode(aToken); + pFontNode->SetSubNodes(0,rNodeStack.Pop()); + rNodeStack.Push(pFontNode); + } + } + + } +} + +//////////////////////////////////////////////////////////// + +class SmXMLDocContext_Impl : public SmXMLImportContext +{ +public: + SmXMLDocContext_Impl( SmXMLImport &rImport, sal_uInt16 nPrfx, + const OUString& rLName) + : SmXMLImportContext(rImport,nPrfx,rLName) {} + + virtual SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference< xml::sax::XAttributeList > &xAttrList); + + void EndElement(); +}; + +//////////////////////////////////////////////////////////// + +/*avert thy gaze from the proginator*/ +class SmXMLRowContext_Impl : public SmXMLDocContext_Impl +{ +protected: + ULONG nElementCount; + +public: + SmXMLRowContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix, + const OUString& rLName) + : SmXMLDocContext_Impl(rImport,nPrefix,rLName) + { nElementCount = GetSmImport().GetNodeStack().Count(); } + + virtual SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference< xml::sax::XAttributeList > &xAttrList); + + SvXMLImportContext *StrictCreateChildContext(sal_uInt16 nPrefix, + const OUString& rLocalName, + const uno::Reference< xml::sax::XAttributeList > &xAttrList); + + void EndElement(); +}; + +//////////////////////////////////////////////////////////// + +class SmXMLFracContext_Impl : public SmXMLRowContext_Impl +{ +public: + SmXMLFracContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix, + const OUString& rLName) + : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {} + + void EndElement(); +}; + +//////////////////////////////////////////////////////////// + +class SmXMLSqrtContext_Impl : public SmXMLRowContext_Impl +{ +public: + SmXMLSqrtContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix, + const OUString& rLName) + : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {} + + void EndElement(); +}; + +//////////////////////////////////////////////////////////// + +class SmXMLRootContext_Impl : public SmXMLRowContext_Impl +{ +public: + SmXMLRootContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix, + const OUString& rLName) + : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {} + + void EndElement(); +}; + +//////////////////////////////////////////////////////////// + +class SmXMLStyleContext_Impl : public SmXMLRowContext_Impl +{ +protected: + SmXMLContext_Helper aStyleHelper; + +public: + /*Right now the style tag is completely ignored*/ + SmXMLStyleContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix, + const OUString& rLName) : SmXMLRowContext_Impl(rImport,nPrefix,rLName), + aStyleHelper(*this) {} + + void EndElement(); + void StartElement(const uno::Reference< xml::sax::XAttributeList > &xAttrList ); +}; + +void SmXMLStyleContext_Impl::StartElement(const uno::Reference< + xml::sax::XAttributeList > & xAttrList ) +{ +#if 1 + aStyleHelper.RetrieveAttrs(xAttrList); +#else + sal_Int8 nOldIsBold=nIsBold; + sal_Int8 nOldIsItalic=nIsItalic; + double nOldFontSize=nFontSize; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + OUString sOldFontFamily = sFontFamily; + for (sal_Int16 i=0;i<nAttrCount;i++) + { + OUString sAttrName = xAttrList->getNameByIndex(i); + OUString aLocalName; + sal_uInt16 nPrefix = GetImport().GetNamespaceMap(). + GetKeyByAttrName(sAttrName,&aLocalName); + OUString sValue = xAttrList->getValueByIndex(i); + const SvXMLTokenMap &rAttrTokenMap = + GetSmImport().GetPresLayoutAttrTokenMap(); + switch(rAttrTokenMap.Get(nPrefix,aLocalName)) + { + case XML_TOK_FONTWEIGHT: + nIsBold = sValue.equals(GetXMLToken(XML_BOLD)); + break; + case XML_TOK_FONTSTYLE: + nIsItalic = sValue.equals(GetXMLToken(XML_ITALIC)); + break; + case XML_TOK_FONTSIZE: + SvXMLUnitConverter::convertDouble(nFontSize,sValue); + GetSmImport().GetMM100UnitConverter(). + setXMLMeasureUnit(MAP_POINT); + if (-1 == sValue.indexOf(GetXMLToken(XML_UNIT_PT))) + if (-1 == sValue.indexOf('%')) + nFontSize=0.0; + else + { + GetSmImport().GetMM100UnitConverter(). + setXMLMeasureUnit(MAP_RELATIVE); + } + break; + case XML_TOK_FONTFAMILY: + sFontFamily = sValue; + break; + case XML_TOK_COLOR: + sColor = sValue; + break; + default: + break; + } + } + + if ((nOldIsBold!=nIsBold) || (nOldIsItalic!=nIsItalic) || + (nOldFontSize!=nFontSize) || (sOldFontFamily!=sFontFamily) + || sColor.getLength()) + bFontNodeNeeded=sal_True; + else + bFontNodeNeeded=sal_False; +#endif +} + + +void SmXMLStyleContext_Impl::EndElement() +{ + /* + <mstyle> accepts any number of arguments; if this number is not 1, its + contents are treated as a single "inferred <mrow>" containing its + arguments + */ + SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + if (rNodeStack.Count() - nElementCount > 1) + SmXMLRowContext_Impl::EndElement(); +#if 1 + aStyleHelper.ApplyAttrs(); +#else + if (bFontNodeNeeded) + { + SmToken aToken; + aToken.cMathChar = '\0'; + aToken.nGroup = 0; + aToken.nLevel = 5; + + if (nIsBold != -1) + { + if (nIsBold) + aToken.eType = TBOLD; + else + aToken.eType = TNBOLD; + SmStructureNode *pFontNode = static_cast<SmStructureNode *> + (new SmFontNode(aToken)); + pFontNode->SetSubNodes(0,rNodeStack.Pop()); + rNodeStack.Push(pFontNode); + } + if (nIsItalic != -1) + { + if (nIsItalic) + aToken.eType = TITALIC; + else + aToken.eType = TNITALIC; + SmStructureNode *pFontNode = static_cast<SmStructureNode *> + (new SmFontNode(aToken)); + pFontNode->SetSubNodes(0,rNodeStack.Pop()); + rNodeStack.Push(pFontNode); + } + if (nFontSize != 0.0) + { + aToken.eType = TSIZE; + SmFontNode *pFontNode = new SmFontNode(aToken); + + if (MAP_RELATIVE == GetSmImport().GetMM100UnitConverter(). + getXMLMeasureUnit()) + { + if (nFontSize < 100.00) + pFontNode->SetSizeParameter(Fraction(100.00/nFontSize), + FNTSIZ_DIVIDE); + else + pFontNode->SetSizeParameter(Fraction(nFontSize/100.00), + FNTSIZ_MULTIPLY); + } + else + pFontNode->SetSizeParameter(Fraction(nFontSize),FNTSIZ_ABSOLUT); + + pFontNode->SetSubNodes(0,rNodeStack.Pop()); + rNodeStack.Push(pFontNode); + } + if (sFontFamily.getLength()) + { + if (sFontFamily.equalsIgnoreCase(GetXMLToken(XML_FIXED))) + aToken.eType = TFIXED; + else if (sFontFamily.equalsIgnoreCase(OUString( + RTL_CONSTASCII_USTRINGPARAM("sans")))) + aToken.eType = TSANS; + else if (sFontFamily.equalsIgnoreCase(OUString( + RTL_CONSTASCII_USTRINGPARAM("serif")))) + aToken.eType = TSERIF; + else //Just give up, we need to extend our font mechanism to be + //more general + return; + + aToken.aText = sFontFamily; + SmFontNode *pFontNode = new SmFontNode(aToken); + pFontNode->SetSubNodes(0,rNodeStack.Pop()); + rNodeStack.Push(pFontNode); + } + if (sColor.getLength()) + { + //Again we can only handle a small set of colours in + //StarMath for now. + const SvXMLTokenMap& rTokenMap = + GetSmImport().GetColorTokenMap(); + aToken.eType = static_cast<SmTokenType>(rTokenMap.Get( + XML_NAMESPACE_MATH, sColor)); + if (aToken.eType != -1) + { + SmFontNode *pFontNode = new SmFontNode(aToken); + pFontNode->SetSubNodes(0,rNodeStack.Pop()); + rNodeStack.Push(pFontNode); + } + } + + } +#endif +} + +//////////////////////////////////////////////////////////// + +class SmXMLPaddedContext_Impl : public SmXMLRowContext_Impl +{ +public: + /*Right now the style tag is completely ignored*/ + SmXMLPaddedContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix, + const OUString& rLName) + : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {} + + void EndElement(); +}; + +void SmXMLPaddedContext_Impl::EndElement() +{ + /* + <mpadded> accepts any number of arguments; if this number is not 1, its + contents are treated as a single "inferred <mrow>" containing its + arguments + */ + if (GetSmImport().GetNodeStack().Count() - nElementCount > 1) + SmXMLRowContext_Impl::EndElement(); +} + +//////////////////////////////////////////////////////////// + +class SmXMLPhantomContext_Impl : public SmXMLRowContext_Impl +{ +public: + /*Right now the style tag is completely ignored*/ + SmXMLPhantomContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix, + const OUString& rLName) + : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {} + + void EndElement(); +}; + +void SmXMLPhantomContext_Impl::EndElement() +{ + /* + <mphantom> accepts any number of arguments; if this number is not 1, its + contents are treated as a single "inferred <mrow>" containing its + arguments + */ + if (GetSmImport().GetNodeStack().Count() - nElementCount > 1) + SmXMLRowContext_Impl::EndElement(); + + SmToken aToken; + aToken.cMathChar = '\0'; + aToken.nGroup = 0; + aToken.nLevel = 5; + aToken.eType = TPHANTOM; + + SmStructureNode *pPhantom = static_cast<SmStructureNode *> + (new SmFontNode(aToken)); + SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + pPhantom->SetSubNodes(0,rNodeStack.Pop()); + rNodeStack.Push(pPhantom); +} + +//////////////////////////////////////////////////////////// + +class SmXMLFencedContext_Impl : public SmXMLRowContext_Impl +{ +protected: + sal_Unicode cBegin; + sal_Unicode cEnd; + +public: + SmXMLFencedContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix, + const OUString& rLName) + : SmXMLRowContext_Impl(rImport,nPrefix,rLName), + cBegin('('), cEnd(')') {} + + void StartElement(const uno::Reference< xml::sax::XAttributeList > & xAttrList ); + void EndElement(); +}; + + +void SmXMLFencedContext_Impl::StartElement(const uno::Reference< + xml::sax::XAttributeList > & xAttrList ) +{ + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for (sal_Int16 i=0;i<nAttrCount;i++) + { + OUString sAttrName = xAttrList->getNameByIndex(i); + OUString aLocalName; + sal_uInt16 nPrefix = GetImport().GetNamespaceMap(). + GetKeyByAttrName(sAttrName,&aLocalName); + OUString sValue = xAttrList->getValueByIndex(i); + const SvXMLTokenMap &rAttrTokenMap = + GetSmImport().GetFencedAttrTokenMap(); + switch(rAttrTokenMap.Get(nPrefix,aLocalName)) + { + //temp, starmath cannot handle multichar brackets (I think) + case XML_TOK_OPEN: + cBegin = sValue[0]; + break; + case XML_TOK_CLOSE: + cEnd = sValue[0]; + break; + default: + /*Go to superclass*/ + break; + } + } +} + + +void SmXMLFencedContext_Impl::EndElement() +{ + SmToken aToken; + aToken.cMathChar = '\0'; + aToken.nGroup = 0; + aToken.aText = ','; + aToken.eType = TLEFT; + aToken.nLevel = 5; + + aToken.eType = TLPARENT; + aToken.cMathChar = cBegin; + SmStructureNode *pSNode = new SmBraceNode(aToken); + SmNode *pLeft = new SmMathSymbolNode(aToken); + + aToken.cMathChar = cEnd; + aToken.eType = TRPARENT; + SmNode *pRight = new SmMathSymbolNode(aToken); + + SmNodeArray aRelationArray; + SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + + aToken.cMathChar = '\0'; + aToken.aText = ','; + aToken.eType = TIDENT; + + ULONG i = rNodeStack.Count() - nElementCount; + if (rNodeStack.Count() - nElementCount > 1) + i += rNodeStack.Count() - 1 - nElementCount; + aRelationArray.resize(i); + while (rNodeStack.Count() > nElementCount) + { + aRelationArray[--i] = rNodeStack.Pop(); + if (i > 1 && rNodeStack.Count() > 1) + aRelationArray[--i] = new SmGlyphSpecialNode(aToken); + } + + SmToken aDummy; + SmStructureNode *pBody = new SmExpressionNode(aDummy); + pBody->SetSubNodes(aRelationArray); + + + pSNode->SetSubNodes(pLeft,pBody,pRight); + pSNode->SetScaleMode(SCALE_HEIGHT); + GetSmImport().GetNodeStack().Push(pSNode); +} + + +//////////////////////////////////////////////////////////// + +class SmXMLErrorContext_Impl : public SmXMLRowContext_Impl +{ +public: + SmXMLErrorContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix, + const OUString& rLName) + : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {} + + void EndElement(); +}; + +void SmXMLErrorContext_Impl::EndElement() +{ + /*Right now the error tag is completely ignored, what + can I do with it in starmath, ?, maybe we need a + report window ourselves, do a test for validity of + the xml input, use merrors, and then generate + the markup inside the merror with a big red colour + of something. For now just throw them all away. + */ + SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + while (rNodeStack.Count() > nElementCount) + { + SmNode *pNode = rNodeStack.Pop(); + delete pNode; + } +} + +//////////////////////////////////////////////////////////// + +class SmXMLNumberContext_Impl : public SmXMLImportContext +{ +protected: + SmToken aToken; + +public: + SmXMLNumberContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix, + const OUString& rLName) + : SmXMLImportContext(rImport,nPrefix,rLName) + { + aToken.cMathChar = '\0'; + aToken.nGroup = 0; + aToken.nLevel = 5; + aToken.eType = TNUMBER; + } + + virtual void TCharacters(const OUString &rChars); + + void EndElement(); +}; + +void SmXMLNumberContext_Impl::TCharacters(const OUString &rChars) +{ + aToken.aText = rChars; +} + +void SmXMLNumberContext_Impl::EndElement() +{ + GetSmImport().GetNodeStack().Push(new SmTextNode(aToken,FNT_NUMBER)); +} + +//////////////////////////////////////////////////////////// + +class SmXMLAnnotationContext_Impl : public SmXMLImportContext +{ + sal_Bool bIsStarMath; + +public: + SmXMLAnnotationContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix, + const OUString& rLName) + : SmXMLImportContext(rImport,nPrefix,rLName), bIsStarMath(sal_False) {} + + virtual void Characters(const OUString &rChars); + + void StartElement(const uno::Reference<xml::sax::XAttributeList > & xAttrList ); +}; + +void SmXMLAnnotationContext_Impl::StartElement(const uno::Reference< + xml::sax::XAttributeList > & xAttrList ) +{ + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for (sal_Int16 i=0;i<nAttrCount;i++) + { + OUString sAttrName = xAttrList->getNameByIndex(i); + OUString aLocalName; + sal_uInt16 nPrefix = GetImport().GetNamespaceMap(). + GetKeyByAttrName(sAttrName,&aLocalName); + + OUString sValue = xAttrList->getValueByIndex(i); + const SvXMLTokenMap &rAttrTokenMap = + GetSmImport().GetAnnotationAttrTokenMap(); + switch(rAttrTokenMap.Get(nPrefix,aLocalName)) + { + case XML_TOK_ENCODING: + bIsStarMath= sValue.equals( + OUString(RTL_CONSTASCII_USTRINGPARAM("StarMath 5.0"))); + break; + default: + break; + } + } +} + +void SmXMLAnnotationContext_Impl::Characters(const OUString &rChars) +{ + if (bIsStarMath) + GetSmImport().GetText().Append(String(rChars)); +} + +//////////////////////////////////////////////////////////// + +class SmXMLTextContext_Impl : public SmXMLImportContext +{ +protected: + SmToken aToken; + +public: + SmXMLTextContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix, + const OUString& rLName) + : SmXMLImportContext(rImport,nPrefix,rLName) + { + aToken.cMathChar = '\0'; + aToken.nGroup = 0; + aToken.nLevel = 5; + aToken.eType = TTEXT; + } + + virtual void TCharacters(const OUString &rChars); + + void EndElement(); +}; + +void SmXMLTextContext_Impl::TCharacters(const OUString &rChars) +{ + aToken.aText = rChars; +} + +void SmXMLTextContext_Impl::EndElement() +{ + GetSmImport().GetNodeStack().Push(new SmTextNode(aToken,FNT_TEXT)); +} + +//////////////////////////////////////////////////////////// + +class SmXMLStringContext_Impl : public SmXMLImportContext +{ +protected: + SmToken aToken; + +public: + SmXMLStringContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix, + const OUString& rLName) + : SmXMLImportContext(rImport,nPrefix,rLName) + { + aToken.cMathChar = '\0'; + aToken.nGroup = 0; + aToken.nLevel = 5; + aToken.eType = TTEXT; + } + + virtual void TCharacters(const OUString &rChars); + + void EndElement(); +}; + +void SmXMLStringContext_Impl::TCharacters(const OUString &rChars) +{ + /* + The content of <ms> elements should be rendered with visible "escaping" of + certain characters in the content, including at least "double quote" + itself, and preferably whitespace other than individual blanks. The intent + is for the viewer to see that the expression is a string literal, and to + see exactly which characters form its content. For example, <ms>double + quote is "</ms> might be rendered as "double quote is \"". + + Obviously this isn't fully done here. + */ + aToken.aText.Erase(); + aToken.aText += '\"'; + aToken.aText += String(rChars); + aToken.aText += '\"'; +} + +void SmXMLStringContext_Impl::EndElement() +{ + GetSmImport().GetNodeStack().Push(new SmTextNode(aToken,FNT_FIXED)); +} + +//////////////////////////////////////////////////////////// + +class SmXMLIdentifierContext_Impl : public SmXMLImportContext +{ +protected: + SmXMLContext_Helper aStyleHelper; + SmToken aToken; + +public: + SmXMLIdentifierContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix, + const OUString& rLName) + : SmXMLImportContext(rImport,nPrefix,rLName),aStyleHelper(*this) + { + aToken.cMathChar = '\0'; + aToken.nGroup = 0; + aToken.nLevel = 5; + aToken.eType = TIDENT; + } + + void TCharacters(const OUString &rChars); + void StartElement(const uno::Reference< xml::sax::XAttributeList > & xAttrList ) + { + aStyleHelper.RetrieveAttrs(xAttrList); + }; + void EndElement(); +}; + +void SmXMLIdentifierContext_Impl::EndElement() +{ + SmTextNode *pNode = 0; + //we will handle identifier italic/normal here instead of with a standalone + //font node + if (((aStyleHelper.nIsItalic == -1) && (aToken.aText.Len() > 1)) + || ((aStyleHelper.nIsItalic == 0) && (aToken.aText.Len() == 1))) + { + pNode = new SmTextNode(aToken,FNT_FUNCTION); + pNode->GetFont().SetItalic(ITALIC_NONE); + aStyleHelper.nIsItalic = -1; + } + else + pNode = new SmTextNode(aToken,FNT_VARIABLE); + if (aStyleHelper.bFontNodeNeeded && aStyleHelper.nIsItalic != -1) + { + if (aStyleHelper.nIsItalic) + pNode->GetFont().SetItalic(ITALIC_NORMAL); + else + pNode->GetFont().SetItalic(ITALIC_NONE); + } + + if ((-1!=aStyleHelper.nIsBold) || (0.0!=aStyleHelper.nFontSize) || + (aStyleHelper.sFontFamily.getLength()) || + aStyleHelper.sColor.getLength()) + aStyleHelper.bFontNodeNeeded=sal_True; + else + aStyleHelper.bFontNodeNeeded=sal_False; + if (aStyleHelper.bFontNodeNeeded) + aStyleHelper.ApplyAttrs(); + GetSmImport().GetNodeStack().Push(pNode); +} + +void SmXMLIdentifierContext_Impl::TCharacters(const OUString &rChars) +{ + aToken.aText = rChars; +} + +//////////////////////////////////////////////////////////// + +class SmXMLOperatorContext_Impl : public SmXMLImportContext +{ + sal_Bool bIsStretchy; + +protected: + SmToken aToken; + +public: + SmXMLOperatorContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix, + const OUString& rLName) + : SmXMLImportContext(rImport,nPrefix,rLName), bIsStretchy(sal_False) + { + aToken.nGroup = 0; + aToken.eType = TSPECIAL; + aToken.nLevel = 5; + } + + void TCharacters(const OUString &rChars); + void StartElement(const uno::Reference< xml::sax::XAttributeList > &xAttrList ); + void EndElement(); +}; + +void SmXMLOperatorContext_Impl::TCharacters(const OUString &rChars) +{ + aToken.cMathChar = rChars[0]; +} + +void SmXMLOperatorContext_Impl::EndElement() +{ + SmMathSymbolNode *pNode = new SmMathSymbolNode(aToken); + //For stretchy scaling the scaling must be retrieved from this node + //and applied to the expression itself so as to get the expression + //to scale the operator to the height of the expression itself + if (bIsStretchy) + pNode->SetScaleMode(SCALE_HEIGHT); + GetSmImport().GetNodeStack().Push(pNode); +} + + + +void SmXMLOperatorContext_Impl::StartElement(const uno::Reference< + xml::sax::XAttributeList > & xAttrList ) +{ + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for (sal_Int16 i=0;i<nAttrCount;i++) + { + OUString sAttrName = xAttrList->getNameByIndex(i); + OUString aLocalName; + sal_uInt16 nPrefix = GetImport().GetNamespaceMap(). + GetKeyByAttrName(sAttrName,&aLocalName); + + OUString sValue = xAttrList->getValueByIndex(i); + const SvXMLTokenMap &rAttrTokenMap = + GetSmImport().GetOperatorAttrTokenMap(); + switch(rAttrTokenMap.Get(nPrefix,aLocalName)) + { + case XML_TOK_STRETCHY: + bIsStretchy = sValue.equals( + GetXMLToken(XML_TRUE)); + break; + default: + break; + } + } +} + + +//////////////////////////////////////////////////////////// + +class SmXMLSpaceContext_Impl : public SmXMLImportContext +{ +public: + SmXMLSpaceContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix, + const OUString& rLName) + : SmXMLImportContext(rImport,nPrefix,rLName) {} + + void StartElement(const uno::Reference< xml::sax::XAttributeList >& xAttrList ); +}; + +void SmXMLSpaceContext_Impl::StartElement( + const uno::Reference<xml::sax::XAttributeList > & /*xAttrList*/ ) +{ + SmToken aToken; + aToken.cMathChar = '\0'; + aToken.nGroup = 0; + aToken.eType = TBLANK; + aToken.nLevel = 5; + SmBlankNode *pBlank = new SmBlankNode(aToken); + pBlank->IncreaseBy(aToken); + GetSmImport().GetNodeStack().Push(pBlank); +} + +//////////////////////////////////////////////////////////// + +class SmXMLSubContext_Impl : public SmXMLRowContext_Impl +{ +protected: + void GenericEndElement(SmTokenType eType,SmSubSup aSubSup); + +public: + SmXMLSubContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix, + const OUString& rLName) + : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {} + + void EndElement() + { + GenericEndElement(TRSUB,RSUB); + } +}; + + +void SmXMLSubContext_Impl::GenericEndElement(SmTokenType eType, SmSubSup eSubSup) +{ + /*The <msub> element requires exactly 2 arguments.*/ + DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount == 2, + "Sub has not two arguments"); + SmToken aToken; + aToken.cMathChar = '\0'; + aToken.nGroup = 0; + aToken.nLevel = 0; + aToken.eType = eType; + SmSubSupNode *pNode = new SmSubSupNode(aToken); + SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + + // initialize subnodes array + SmNodeArray aSubNodes; + aSubNodes.resize(1 + SUBSUP_NUM_ENTRIES); + for (ULONG i = 1; i < aSubNodes.size(); i++) + aSubNodes[i] = NULL; + + aSubNodes[eSubSup+1] = rNodeStack.Pop(); + aSubNodes[0] = rNodeStack.Pop(); + pNode->SetSubNodes(aSubNodes); + rNodeStack.Push(pNode); +} + +//////////////////////////////////////////////////////////// + +class SmXMLSupContext_Impl : public SmXMLSubContext_Impl +{ +public: + SmXMLSupContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix, + const OUString& rLName) + : SmXMLSubContext_Impl(rImport,nPrefix,rLName) {} + + void EndElement() + { + GenericEndElement(TRSUP,RSUP); + } +}; + +//////////////////////////////////////////////////////////// + +class SmXMLSubSupContext_Impl : public SmXMLRowContext_Impl +{ +protected: + void GenericEndElement(SmTokenType eType, SmSubSup aSub,SmSubSup aSup); + +public: + SmXMLSubSupContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix, + const OUString& rLName) + : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {} + + void EndElement() + { + GenericEndElement(TRSUB,RSUB,RSUP); + } +}; + +void SmXMLSubSupContext_Impl::GenericEndElement(SmTokenType eType, + SmSubSup aSub,SmSubSup aSup) +{ + /*The <msub> element requires exactly 3 arguments.*/ + DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount == 3, + "SubSup has not three arguments"); + + SmToken aToken; + aToken.cMathChar = '\0'; + aToken.nGroup = 0; + aToken.nLevel = 0; + aToken.eType = eType; + SmSubSupNode *pNode = new SmSubSupNode(aToken); + SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + + // initialize subnodes array + SmNodeArray aSubNodes; + aSubNodes.resize(1 + SUBSUP_NUM_ENTRIES); + for (ULONG i = 1; i < aSubNodes.size(); i++) + aSubNodes[i] = NULL; + + aSubNodes[aSup+1] = rNodeStack.Pop(); + aSubNodes[aSub+1] = rNodeStack.Pop(); + aSubNodes[0] = rNodeStack.Pop(); + pNode->SetSubNodes(aSubNodes); + rNodeStack.Push(pNode); +} + +//////////////////////////////////////////////////////////// + +class SmXMLUnderContext_Impl : public SmXMLSubContext_Impl +{ +protected: + sal_Int16 nAttrCount; + +public: + SmXMLUnderContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix, + const OUString& rLName) + : SmXMLSubContext_Impl(rImport,nPrefix,rLName) {} + + void StartElement(const uno::Reference< xml::sax::XAttributeList > &xAttrList ); + void EndElement(); + void HandleAccent(); +}; + +void SmXMLUnderContext_Impl::StartElement(const uno::Reference< + xml::sax::XAttributeList > & xAttrList ) +{ + nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; +} + +void SmXMLUnderContext_Impl::HandleAccent() +{ + DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount == 2, + "Sub has not two arguments"); + + /*Just one special case for the underline thing*/ + SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + SmNode *pTest = rNodeStack.Pop(); + SmToken aToken; + aToken.cMathChar = '\0'; + aToken.nGroup = 0; + aToken.nLevel = 0; + aToken.eType = TUNDERLINE; + + + SmNodeArray aSubNodes; + aSubNodes.resize(2); + + SmStructureNode *pNode = new SmAttributNode(aToken); + if ((pTest->GetToken().cMathChar & 0x0FFF) == 0x0332) + { + aSubNodes[0] = new SmRectangleNode(aToken); + delete pTest; + } + else + aSubNodes[0] = pTest; + + aSubNodes[1] = rNodeStack.Pop(); + pNode->SetSubNodes(aSubNodes); + pNode->SetScaleMode(SCALE_WIDTH); + rNodeStack.Push(pNode); +} + + +void SmXMLUnderContext_Impl::EndElement() +{ + if (!nAttrCount) + GenericEndElement(TCSUB,CSUB); + else + HandleAccent(); +#if 0 + //UnderBrace trick + SmStructureNode *pNode = rNodeStack.Pop(); + if (pNode->GetSubNode(1)->GetToken().cMathChar == (0x0332|0xf000)) + if (pNode->GetSubNode(0)->GetToken().cMathChar == (0x0332|0xf000)) +#endif +} + +//////////////////////////////////////////////////////////// + +class SmXMLOverContext_Impl : public SmXMLSubContext_Impl +{ +protected: + sal_Int16 nAttrCount; + +public: + SmXMLOverContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix, + const OUString& rLName) + : SmXMLSubContext_Impl(rImport,nPrefix,rLName), nAttrCount(0) {} + + void EndElement(); + void StartElement(const uno::Reference< xml::sax::XAttributeList > &xAttrList ); + void HandleAccent(); +}; + + +void SmXMLOverContext_Impl::StartElement(const uno::Reference< + xml::sax::XAttributeList > & xAttrList ) +{ + nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; +} + + +void SmXMLOverContext_Impl::EndElement() +{ + if (!nAttrCount) + GenericEndElement(TCSUP,CSUP); + else + HandleAccent(); +} + + +void SmXMLOverContext_Impl::HandleAccent() +{ + DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount == 2, + "Sub has not two arguments"); + SmToken aToken; + aToken.cMathChar = '\0'; + aToken.nGroup = 0; + aToken.nLevel = 0; + aToken.eType = TACUTE; + + SmAttributNode *pNode = new SmAttributNode(aToken); + SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + + SmNodeArray aSubNodes; + aSubNodes.resize(2); + aSubNodes[0] = rNodeStack.Pop(); + aSubNodes[1] = rNodeStack.Pop(); + pNode->SetSubNodes(aSubNodes); + pNode->SetScaleMode(SCALE_WIDTH); + rNodeStack.Push(pNode); + +} + +//////////////////////////////////////////////////////////// + +class SmXMLUnderOverContext_Impl : public SmXMLSubSupContext_Impl +{ +public: + SmXMLUnderOverContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix, + const OUString& rLName) + : SmXMLSubSupContext_Impl(rImport,nPrefix,rLName) {} + + void EndElement() + { + GenericEndElement(TCSUB,CSUB,CSUP); + } +}; + +//////////////////////////////////////////////////////////// + +class SmXMLMultiScriptsContext_Impl : public SmXMLSubSupContext_Impl +{ + sal_Bool bHasPrescripts; + +public: + SmXMLMultiScriptsContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix, + const OUString& rLName) : + SmXMLSubSupContext_Impl(rImport,nPrefix,rLName), + bHasPrescripts(FALSE) {} + + void EndElement(); + void MiddleElement(); + SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix, + const OUString& rLocalName, + const uno::Reference< xml::sax::XAttributeList > &xAttrList); +}; + +//////////////////////////////////////////////////////////// + +class SmXMLNoneContext_Impl : public SmXMLImportContext +{ +public: + SmXMLNoneContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix, + const OUString& rLName) + : SmXMLImportContext(rImport,nPrefix,rLName) {} + + void EndElement(); +}; + + +void SmXMLNoneContext_Impl::EndElement(void) +{ + SmToken aToken; + aToken.cMathChar = '\0'; + aToken.nGroup = 0; + aToken.aText.Erase(); + aToken.nLevel = 5; + aToken.eType = TIDENT; + GetSmImport().GetNodeStack().Push( + new SmTextNode(aToken,FNT_VARIABLE)); +} + +//////////////////////////////////////////////////////////// + +class SmXMLPrescriptsContext_Impl : public SmXMLImportContext +{ +public: + SmXMLPrescriptsContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix, + const OUString& rLName) + : SmXMLImportContext(rImport,nPrefix,rLName) {} +}; + +//////////////////////////////////////////////////////////// + +class SmXMLTableRowContext_Impl : public SmXMLRowContext_Impl +{ +public: + SmXMLTableRowContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix, + const OUString& rLName) : + SmXMLRowContext_Impl(rImport,nPrefix,rLName) + {} + + SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix, + const OUString& rLocalName, + const uno::Reference< xml::sax::XAttributeList > &xAttrList); +}; + + +//////////////////////////////////////////////////////////// + +class SmXMLTableContext_Impl : public SmXMLTableRowContext_Impl +{ +public: + SmXMLTableContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix, + const OUString& rLName) : + SmXMLTableRowContext_Impl(rImport,nPrefix,rLName) + {} + + void EndElement(); + SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix, + const OUString& rLocalName, + const uno::Reference< xml::sax::XAttributeList > &xAttrList); +}; + + +//////////////////////////////////////////////////////////// + +class SmXMLTableCellContext_Impl : public SmXMLRowContext_Impl +{ +public: + SmXMLTableCellContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix, + const OUString& rLName) : + SmXMLRowContext_Impl(rImport,nPrefix,rLName) + {} +}; + +//////////////////////////////////////////////////////////// + +class SmXMLAlignGroupContext_Impl : public SmXMLRowContext_Impl +{ +public: + SmXMLAlignGroupContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix, + const OUString& rLName) : + SmXMLRowContext_Impl(rImport,nPrefix,rLName) + {} + + /*Don't do anything with alignment for now*/ + void EndElement() + { + } +}; + +//////////////////////////////////////////////////////////// + +class SmXMLActionContext_Impl : public SmXMLRowContext_Impl +{ +public: + SmXMLActionContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix, + const OUString& rLName) : + SmXMLRowContext_Impl(rImport,nPrefix,rLName) + {} + + void EndElement(); +}; + +//////////////////////////////////////////////////////////// + +// NB: virtually inherit so we can multiply inherit properly +// in SmXMLFlatDocContext_Impl +class SmXMLOfficeContext_Impl : public virtual SvXMLImportContext +{ +public: + SmXMLOfficeContext_Impl( SmXMLImport &rImport, sal_uInt16 nPrfx, + const OUString& rLName) + : SvXMLImportContext(rImport,nPrfx,rLName) {} + + virtual SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference< xml::sax::XAttributeList > &xAttrList); +}; + +SvXMLImportContext *SmXMLOfficeContext_Impl::CreateChildContext(sal_uInt16 nPrefix, + const OUString& rLocalName, + const uno::Reference< xml::sax::XAttributeList > &xAttrList) +{ + SvXMLImportContext *pContext = 0; + if ( XML_NAMESPACE_OFFICE == nPrefix && + rLocalName == GetXMLToken(XML_META) ) + { + DBG_WARNING("XML_TOK_DOC_META: should not have come here, maybe document is invalid?"); + } + else if ( XML_NAMESPACE_OFFICE == nPrefix && + rLocalName == GetXMLToken(XML_SETTINGS) ) + { + pContext = new XMLDocumentSettingsContext( GetImport(), + XML_NAMESPACE_OFFICE, rLocalName, + xAttrList ); + } + else + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + + return pContext; +} + +//////////////////////////////////////////////////////////// + +// context for flat file xml format +class SmXMLFlatDocContext_Impl + : public SmXMLOfficeContext_Impl, public SvXMLMetaDocumentContext +{ +public: + SmXMLFlatDocContext_Impl( SmXMLImport& i_rImport, + USHORT i_nPrefix, const OUString & i_rLName, + const uno::Reference<document::XDocumentProperties>& i_xDocProps, + const uno::Reference<xml::sax::XDocumentHandler>& i_xDocBuilder); + + virtual ~SmXMLFlatDocContext_Impl(); + + virtual SvXMLImportContext *CreateChildContext(USHORT i_nPrefix, const OUString& i_rLocalName, const uno::Reference<xml::sax::XAttributeList>& i_xAttrList); +}; + +SmXMLFlatDocContext_Impl::SmXMLFlatDocContext_Impl( SmXMLImport& i_rImport, + USHORT i_nPrefix, const OUString & i_rLName, + const uno::Reference<document::XDocumentProperties>& i_xDocProps, + const uno::Reference<xml::sax::XDocumentHandler>& i_xDocBuilder) : + SvXMLImportContext(i_rImport, i_nPrefix, i_rLName), + SmXMLOfficeContext_Impl(i_rImport, i_nPrefix, i_rLName), + SvXMLMetaDocumentContext(i_rImport, i_nPrefix, i_rLName, + i_xDocProps, i_xDocBuilder) +{ +} + +SmXMLFlatDocContext_Impl::~SmXMLFlatDocContext_Impl() +{ +} + +SvXMLImportContext *SmXMLFlatDocContext_Impl::CreateChildContext( + USHORT i_nPrefix, const OUString& i_rLocalName, + const uno::Reference<xml::sax::XAttributeList>& i_xAttrList) +{ + // behave like meta base class iff we encounter office:meta + if ( XML_NAMESPACE_OFFICE == i_nPrefix && + i_rLocalName == GetXMLToken(XML_META) ) + { + return SvXMLMetaDocumentContext::CreateChildContext( + i_nPrefix, i_rLocalName, i_xAttrList ); + } + else + { + return SmXMLOfficeContext_Impl::CreateChildContext( + i_nPrefix, i_rLocalName, i_xAttrList ); + } +} + +//////////////////////////////////////////////////////////// + +static __FAR_DATA SvXMLTokenMapEntry aPresLayoutElemTokenMap[] = +{ + { XML_NAMESPACE_MATH, XML_SEMANTICS, XML_TOK_SEMANTICS }, + { XML_NAMESPACE_MATH, XML_MATH, XML_TOK_MATH }, + { XML_NAMESPACE_MATH, XML_MSTYLE, XML_TOK_MSTYLE }, + { XML_NAMESPACE_MATH, XML_MERROR, XML_TOK_MERROR }, + { XML_NAMESPACE_MATH, XML_MPHANTOM, XML_TOK_MPHANTOM }, + { XML_NAMESPACE_MATH, XML_MROW, XML_TOK_MROW }, + { XML_NAMESPACE_MATH, XML_MFRAC, XML_TOK_MFRAC }, + { XML_NAMESPACE_MATH, XML_MSQRT, XML_TOK_MSQRT }, + { XML_NAMESPACE_MATH, XML_MROOT, XML_TOK_MROOT }, + { XML_NAMESPACE_MATH, XML_MSUB, XML_TOK_MSUB }, + { XML_NAMESPACE_MATH, XML_MSUP, XML_TOK_MSUP }, + { XML_NAMESPACE_MATH, XML_MSUBSUP, XML_TOK_MSUBSUP }, + { XML_NAMESPACE_MATH, XML_MUNDER, XML_TOK_MUNDER }, + { XML_NAMESPACE_MATH, XML_MOVER, XML_TOK_MOVER }, + { XML_NAMESPACE_MATH, XML_MUNDEROVER, XML_TOK_MUNDEROVER }, + { XML_NAMESPACE_MATH, XML_MMULTISCRIPTS, XML_TOK_MMULTISCRIPTS }, + { XML_NAMESPACE_MATH, XML_MTABLE, XML_TOK_MTABLE }, + { XML_NAMESPACE_MATH, XML_MACTION, XML_TOK_MACTION }, + { XML_NAMESPACE_MATH, XML_MFENCED, XML_TOK_MFENCED }, + { XML_NAMESPACE_MATH, XML_MPADDED, XML_TOK_MPADDED }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aPresLayoutAttrTokenMap[] = +{ + { XML_NAMESPACE_MATH, XML_FONTWEIGHT, XML_TOK_FONTWEIGHT }, + { XML_NAMESPACE_MATH, XML_FONTSTYLE, XML_TOK_FONTSTYLE }, + { XML_NAMESPACE_MATH, XML_FONTSIZE, XML_TOK_FONTSIZE }, + { XML_NAMESPACE_MATH, XML_FONTFAMILY, XML_TOK_FONTFAMILY }, + { XML_NAMESPACE_MATH, XML_COLOR, XML_TOK_COLOR }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aFencedAttrTokenMap[] = +{ + { XML_NAMESPACE_MATH, XML_OPEN, XML_TOK_OPEN }, + { XML_NAMESPACE_MATH, XML_CLOSE, XML_TOK_CLOSE }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aOperatorAttrTokenMap[] = +{ + { XML_NAMESPACE_MATH, XML_STRETCHY, XML_TOK_STRETCHY }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aAnnotationAttrTokenMap[] = +{ + { XML_NAMESPACE_MATH, XML_ENCODING, XML_TOK_ENCODING }, + XML_TOKEN_MAP_END +}; + + +static __FAR_DATA SvXMLTokenMapEntry aPresElemTokenMap[] = +{ + { XML_NAMESPACE_MATH, XML_ANNOTATION, XML_TOK_ANNOTATION }, + { XML_NAMESPACE_MATH, XML_MI, XML_TOK_MI }, + { XML_NAMESPACE_MATH, XML_MN, XML_TOK_MN }, + { XML_NAMESPACE_MATH, XML_MO, XML_TOK_MO }, + { XML_NAMESPACE_MATH, XML_MTEXT, XML_TOK_MTEXT }, + { XML_NAMESPACE_MATH, XML_MSPACE,XML_TOK_MSPACE }, + { XML_NAMESPACE_MATH, XML_MS, XML_TOK_MS }, + { XML_NAMESPACE_MATH, XML_MALIGNGROUP, XML_TOK_MALIGNGROUP }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aPresScriptEmptyElemTokenMap[] = +{ + { XML_NAMESPACE_MATH, XML_MPRESCRIPTS, XML_TOK_MPRESCRIPTS }, + { XML_NAMESPACE_MATH, XML_NONE, XML_TOK_NONE }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aPresTableElemTokenMap[] = +{ + { XML_NAMESPACE_MATH, XML_MTR, XML_TOK_MTR }, + { XML_NAMESPACE_MATH, XML_MTD, XML_TOK_MTD }, + XML_TOKEN_MAP_END +}; + +static __FAR_DATA SvXMLTokenMapEntry aColorTokenMap[] = +{ + { XML_NAMESPACE_MATH, XML_BLACK, TBLACK}, + { XML_NAMESPACE_MATH, XML_WHITE, TWHITE}, + { XML_NAMESPACE_MATH, XML_RED, TRED}, + { XML_NAMESPACE_MATH, XML_GREEN, TGREEN}, + { XML_NAMESPACE_MATH, XML_BLUE, TBLUE}, + { XML_NAMESPACE_MATH, XML_AQUA, TCYAN}, + { XML_NAMESPACE_MATH, XML_FUCHSIA, TMAGENTA}, + { XML_NAMESPACE_MATH, XML_YELLOW, TYELLOW}, + XML_TOKEN_MAP_END +}; + + +//////////////////////////////////////////////////////////// + +const SvXMLTokenMap& SmXMLImport::GetPresLayoutElemTokenMap() +{ + if (!pPresLayoutElemTokenMap) + pPresLayoutElemTokenMap = new SvXMLTokenMap(aPresLayoutElemTokenMap); + return *pPresLayoutElemTokenMap; +} + +const SvXMLTokenMap& SmXMLImport::GetPresLayoutAttrTokenMap() +{ + if (!pPresLayoutAttrTokenMap) + pPresLayoutAttrTokenMap = new SvXMLTokenMap(aPresLayoutAttrTokenMap); + return *pPresLayoutAttrTokenMap; +} + + +const SvXMLTokenMap& SmXMLImport::GetFencedAttrTokenMap() +{ + if (!pFencedAttrTokenMap) + pFencedAttrTokenMap = new SvXMLTokenMap(aFencedAttrTokenMap); + return *pFencedAttrTokenMap; +} + +const SvXMLTokenMap& SmXMLImport::GetOperatorAttrTokenMap() +{ + if (!pOperatorAttrTokenMap) + pOperatorAttrTokenMap = new SvXMLTokenMap(aOperatorAttrTokenMap); + return *pOperatorAttrTokenMap; +} + +const SvXMLTokenMap& SmXMLImport::GetAnnotationAttrTokenMap() +{ + if (!pAnnotationAttrTokenMap) + pAnnotationAttrTokenMap = new SvXMLTokenMap(aAnnotationAttrTokenMap); + return *pAnnotationAttrTokenMap; +} + +const SvXMLTokenMap& SmXMLImport::GetPresElemTokenMap() +{ + if (!pPresElemTokenMap) + pPresElemTokenMap = new SvXMLTokenMap(aPresElemTokenMap); + return *pPresElemTokenMap; +} + +const SvXMLTokenMap& SmXMLImport::GetPresScriptEmptyElemTokenMap() +{ + if (!pPresScriptEmptyElemTokenMap) + pPresScriptEmptyElemTokenMap = new + SvXMLTokenMap(aPresScriptEmptyElemTokenMap); + return *pPresScriptEmptyElemTokenMap; +} + +const SvXMLTokenMap& SmXMLImport::GetPresTableElemTokenMap() +{ + if (!pPresTableElemTokenMap) + pPresTableElemTokenMap = new SvXMLTokenMap(aPresTableElemTokenMap); + return *pPresTableElemTokenMap; +} + +const SvXMLTokenMap& SmXMLImport::GetColorTokenMap() +{ + if (!pColorTokenMap) + pColorTokenMap = new SvXMLTokenMap(aColorTokenMap); + return *pColorTokenMap; +} + +//////////////////////////////////////////////////////////// + +SvXMLImportContext *SmXMLDocContext_Impl::CreateChildContext( + sal_uInt16 nPrefix, + const OUString& rLocalName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList) +{ + SvXMLImportContext* pContext = 0L; + + const SvXMLTokenMap& rTokenMap = GetSmImport().GetPresLayoutElemTokenMap(); + + //UINT32 nTest = rTokenMap.Get(nPrefix, rLocalName); + + switch(rTokenMap.Get(nPrefix, rLocalName)) + { + //Consider semantics a dummy except for any starmath annotations + case XML_TOK_SEMANTICS: + pContext = GetSmImport().CreateRowContext(nPrefix,rLocalName, + xAttrList); + break; + /*General Layout Schemata*/ + case XML_TOK_MROW: + pContext = GetSmImport().CreateRowContext(nPrefix,rLocalName, + xAttrList); + break; + case XML_TOK_MFRAC: + pContext = GetSmImport().CreateFracContext(nPrefix,rLocalName, + xAttrList); + break; + case XML_TOK_MSQRT: + pContext = GetSmImport().CreateSqrtContext(nPrefix,rLocalName, + xAttrList); + break; + case XML_TOK_MROOT: + pContext = GetSmImport().CreateRootContext(nPrefix,rLocalName, + xAttrList); + break; + case XML_TOK_MSTYLE: + pContext = GetSmImport().CreateStyleContext(nPrefix,rLocalName, + xAttrList); + break; + case XML_TOK_MERROR: + pContext = GetSmImport().CreateErrorContext(nPrefix,rLocalName, + xAttrList); + break; + case XML_TOK_MPADDED: + pContext = GetSmImport().CreatePaddedContext(nPrefix,rLocalName, + xAttrList); + break; + case XML_TOK_MPHANTOM: + pContext = GetSmImport().CreatePhantomContext(nPrefix,rLocalName, + xAttrList); + break; + case XML_TOK_MFENCED: + pContext = GetSmImport().CreateFencedContext(nPrefix,rLocalName, + xAttrList); + break; + /*Script and Limit Schemata*/ + case XML_TOK_MSUB: + pContext = GetSmImport().CreateSubContext(nPrefix,rLocalName, + xAttrList); + break; + case XML_TOK_MSUP: + pContext = GetSmImport().CreateSupContext(nPrefix,rLocalName, + xAttrList); + break; + case XML_TOK_MSUBSUP: + pContext = GetSmImport().CreateSubSupContext(nPrefix,rLocalName, + xAttrList); + break; + case XML_TOK_MUNDER: + pContext = GetSmImport().CreateUnderContext(nPrefix,rLocalName, + xAttrList); + break; + case XML_TOK_MOVER: + pContext = GetSmImport().CreateOverContext(nPrefix,rLocalName, + xAttrList); + break; + case XML_TOK_MUNDEROVER: + pContext = GetSmImport().CreateUnderOverContext(nPrefix,rLocalName, + xAttrList); + break; + case XML_TOK_MMULTISCRIPTS: + pContext = GetSmImport().CreateMultiScriptsContext(nPrefix, + rLocalName, xAttrList); + break; + case XML_TOK_MTABLE: + pContext = GetSmImport().CreateTableContext(nPrefix, + rLocalName, xAttrList); + break; + case XML_TOK_MACTION: + pContext = GetSmImport().CreateActionContext(nPrefix, + rLocalName, xAttrList); + break; + default: + /*Basically theres an implicit mrow around certain bare + *elements, use a RowContext to see if this is one of + *those ones*/ + SmXMLRowContext_Impl aTempContext(GetSmImport(),nPrefix, + GetXMLToken(XML_MROW)); + + pContext = aTempContext.StrictCreateChildContext(nPrefix, + rLocalName, xAttrList); + break; + } + return pContext; +} + +void SmXMLDocContext_Impl::EndElement() +{ + SmNodeArray ContextArray; + ContextArray.resize(1); + SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + + for (ULONG i=0;i< 1;i++) + ContextArray[i] = rNodeStack.Pop(); + + SmToken aDummy; + SmStructureNode *pSNode = new SmLineNode(aDummy); + pSNode->SetSubNodes(ContextArray); + rNodeStack.Push(pSNode); + + SmNodeArray LineArray; + ULONG n = rNodeStack.Count(); + LineArray.resize(n); + for (ULONG j = 0; j < n; j++) + LineArray[n - (j + 1)] = rNodeStack.Pop(); + SmStructureNode *pSNode2 = new SmTableNode(aDummy); + pSNode2->SetSubNodes(LineArray); + rNodeStack.Push(pSNode2); +} + +void SmXMLFracContext_Impl::EndElement() +{ + SmToken aToken; + aToken.cMathChar = '\0'; + aToken.nGroup = 0; + aToken.nLevel = 0; + aToken.eType = TOVER; + SmStructureNode *pSNode = new SmBinVerNode(aToken); + SmNode *pOper = new SmRectangleNode(aToken); + SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + DBG_ASSERT(rNodeStack.Count() - nElementCount == 2, + "Fraction (mfrac) tag is missing component"); + if (rNodeStack.Count() - nElementCount == 2) + { + SmNode *pSecond = rNodeStack.Pop(); + SmNode *pFirst = rNodeStack.Pop(); + pSNode->SetSubNodes(pFirst,pOper,pSecond); + rNodeStack.Push(pSNode); + } +} + +void SmXMLRootContext_Impl::EndElement() +{ + /*The <mroot> element requires exactly 2 arguments.*/ + DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount == 2, + "Root tag is missing component"); + + SmToken aToken; + aToken.cMathChar = MS_SQRT; //Temporary: alert, based on StarSymbol font + aToken.nGroup = 0; + aToken.nLevel = 0; + aToken.eType = TNROOT; + SmStructureNode *pSNode = new SmRootNode(aToken); + SmNode *pOper = new SmRootSymbolNode(aToken); + SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + SmNode *pIndex = rNodeStack.Pop(); + SmNode *pBase = rNodeStack.Pop(); + pSNode->SetSubNodes(pIndex,pOper,pBase); + rNodeStack.Push(pSNode); +} + +void SmXMLSqrtContext_Impl::EndElement() +{ + /* + <msqrt> accepts any number of arguments; if this number is not 1, its + contents are treated as a single "inferred <mrow>" containing its + arguments + */ + if (GetSmImport().GetNodeStack().Count() - nElementCount > 1) + SmXMLRowContext_Impl::EndElement(); + + SmToken aToken; + aToken.cMathChar = MS_SQRT; //Temporary: alert, based on StarSymbol font + aToken.nGroup = 0; + aToken.nLevel = 0; + aToken.eType = TSQRT; + SmStructureNode *pSNode = new SmRootNode(aToken); + SmNode *pOper = new SmRootSymbolNode(aToken); + SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + pSNode->SetSubNodes(0,pOper,rNodeStack.Pop()); + rNodeStack.Push(pSNode); +} + +void SmXMLRowContext_Impl::EndElement() +{ + SmNodeArray aRelationArray; + SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + ULONG nSize = rNodeStack.Count()-nElementCount; + + if (nSize > 0) + { + aRelationArray.resize(nSize); + for (ULONG j=rNodeStack.Count()-nElementCount;j > 0;j--) + aRelationArray[j-1] = rNodeStack.Pop(); + + + //If the first or last element is an operator with stretchyness + //set then we must create a brace node here from those elements, + //removing the stretchness from the operators and applying it to + //ourselves, and creating the appropiate dummy StarMath none bracket + //to balance the arrangement + if (((aRelationArray[0]->GetScaleMode() == SCALE_HEIGHT) + && (aRelationArray[0]->GetType() == NMATH)) + || ((aRelationArray[nSize-1]->GetScaleMode() == SCALE_HEIGHT) + && (aRelationArray[nSize-1]->GetType() == NMATH))) + { + SmToken aToken; + aToken.cMathChar = '\0'; + aToken.nGroup = 0; + aToken.nLevel = 5; + + int nLeft=0,nRight=0; + if ((aRelationArray[0]->GetScaleMode() == SCALE_HEIGHT) + && (aRelationArray[0]->GetType() == NMATH)) + { + aToken = aRelationArray[0]->GetToken(); + nLeft=1; + } + else + aToken.cMathChar = '\0'; + + aToken.eType = TLPARENT; + SmNode *pLeft = new SmMathSymbolNode(aToken); + + if ((aRelationArray[nSize-1]->GetScaleMode() == SCALE_HEIGHT) + && (aRelationArray[nSize-1]->GetType() == NMATH)) + { + aToken = aRelationArray[nSize-1]->GetToken(); + nRight=1; + } + else + aToken.cMathChar = '\0'; + + aToken.eType = TRPARENT; + SmNode *pRight = new SmMathSymbolNode(aToken); + + SmNodeArray aRelationArray2; + + //!! nSize-nLeft-nRight may be < 0 !! + int nRelArrSize = nSize-nLeft-nRight; + if (nRelArrSize > 0) + { + aRelationArray2.resize(nRelArrSize); + for (int i=0;i < nRelArrSize;i++) + aRelationArray2[i] = aRelationArray[i+nLeft]; + } + + SmToken aDummy; + SmStructureNode *pSNode = new SmBraceNode(aToken); + SmStructureNode *pBody = new SmExpressionNode(aDummy); + pBody->SetSubNodes(aRelationArray2); + + pSNode->SetSubNodes(pLeft,pBody,pRight); + pSNode->SetScaleMode(SCALE_HEIGHT); + rNodeStack.Push(pSNode); + return; + } + } + else //Multiple newlines result in empty row elements + { + aRelationArray.resize(1); + SmToken aToken; + aToken.cMathChar = '\0'; + aToken.nGroup = 0; + aToken.nLevel = 5; + aToken.eType = TNEWLINE; + aRelationArray[0] = new SmLineNode(aToken); + } + + SmToken aDummy; + SmStructureNode *pSNode = new SmExpressionNode(aDummy); + pSNode->SetSubNodes(aRelationArray); + rNodeStack.Push(pSNode); +} + + +SvXMLImportContext *SmXMLRowContext_Impl::StrictCreateChildContext( + sal_uInt16 nPrefix, + const OUString& rLocalName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList) +{ + SvXMLImportContext* pContext = 0L; + + const SvXMLTokenMap& rTokenMap = GetSmImport().GetPresElemTokenMap(); + switch(rTokenMap.Get(nPrefix, rLocalName)) + { + /*Note that these should accept malignmark subelements, but do not*/ + case XML_TOK_MN: + pContext = GetSmImport().CreateNumberContext(nPrefix,rLocalName, + xAttrList); + break; + case XML_TOK_MI: + pContext = GetSmImport().CreateIdentifierContext(nPrefix,rLocalName, + xAttrList); + break; + case XML_TOK_MO: + pContext = GetSmImport().CreateOperatorContext(nPrefix,rLocalName, + xAttrList); + break; + case XML_TOK_MTEXT: + pContext = GetSmImport().CreateTextContext(nPrefix,rLocalName, + xAttrList); + break; + case XML_TOK_MSPACE: + pContext = GetSmImport().CreateSpaceContext(nPrefix,rLocalName, + xAttrList); + break; + case XML_TOK_MS: + pContext = GetSmImport().CreateStringContext(nPrefix,rLocalName, + xAttrList); + break; + + /*Note: The maligngroup should only be seen when the row + * (or decendants) are in a table*/ + case XML_TOK_MALIGNGROUP: + pContext = GetSmImport().CreateAlignGroupContext(nPrefix,rLocalName, + xAttrList); + break; + + case XML_TOK_ANNOTATION: + pContext = GetSmImport().CreateAnnotationContext(nPrefix,rLocalName, + xAttrList); + break; + + default: + break; + } + return pContext; +} + + +SvXMLImportContext *SmXMLRowContext_Impl::CreateChildContext( + sal_uInt16 nPrefix, + const OUString& rLocalName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList) +{ + SvXMLImportContext* pContext = StrictCreateChildContext(nPrefix, + rLocalName, xAttrList); + + if (!pContext) + { + //Hmm, unrecognized for this level, check to see if its + //an element that can have an implicit schema around it + pContext = SmXMLDocContext_Impl::CreateChildContext(nPrefix, + rLocalName,xAttrList); + } + return pContext; +} + + +SvXMLImportContext *SmXMLMultiScriptsContext_Impl::CreateChildContext( + sal_uInt16 nPrefix, + const OUString& rLocalName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList) +{ + SvXMLImportContext* pContext = 0L; + + const SvXMLTokenMap& rTokenMap = GetSmImport(). + GetPresScriptEmptyElemTokenMap(); + switch(rTokenMap.Get(nPrefix, rLocalName)) + { + case XML_TOK_MPRESCRIPTS: + MiddleElement(); + pContext = GetSmImport().CreatePrescriptsContext(nPrefix, + rLocalName, xAttrList); + break; + case XML_TOK_NONE: + pContext = GetSmImport().CreateNoneContext(nPrefix,rLocalName, + xAttrList); + break; + default: + pContext = SmXMLRowContext_Impl::CreateChildContext(nPrefix, + rLocalName,xAttrList); + break; + } + return pContext; +} + +void SmXMLMultiScriptsContext_Impl::MiddleElement() +{ + bHasPrescripts=sal_True; + + DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount > 0, + "Sub has no arguments"); + SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + if (rNodeStack.Count()-nElementCount > 1) + { + SmToken aToken; + aToken.cMathChar = '\0'; + aToken.nGroup = 0; + aToken.nLevel = 0; + aToken.eType = TRSUB; + ULONG nFinalCount = rNodeStack.Count()-nElementCount-1; + + SmNodeStack aReverseStack; + while (rNodeStack.Count()-nElementCount) + { + SmNode *pThing = rNodeStack.Pop(); + aReverseStack.Push(pThing); + } + + for (ULONG nCount=0;nCount < nFinalCount;nCount+=2) + { + SmSubSupNode *pNode = new SmSubSupNode(aToken); + + // initialize subnodes array + SmNodeArray aSubNodes; + aSubNodes.resize(1 + SUBSUP_NUM_ENTRIES); + for (ULONG i = 1; i < aSubNodes.size(); i++) + aSubNodes[i] = NULL; + + /*On each loop the base and its sub sup pair becomes the + base for the next loop to which the next sub sup pair is + attached, i.e. wheels within wheels*/ + //if (nCount == 0) + aSubNodes[0] = aReverseStack.Pop(); + + SmNode *pScriptNode = aReverseStack.Pop(); + + if (pScriptNode && ((pScriptNode->GetToken().eType != TIDENT) || + (pScriptNode->GetToken().aText.Len()))) + aSubNodes[RSUB+1] = pScriptNode; + pScriptNode = aReverseStack.Pop(); + if (pScriptNode && ((pScriptNode->GetToken().eType != TIDENT) || + (pScriptNode->GetToken().aText.Len()))) + aSubNodes[RSUP+1] = pScriptNode; + + pNode->SetSubNodes(aSubNodes); + aReverseStack.Push(pNode); + } + rNodeStack.Push(aReverseStack.Pop()); + } +} + + +void SmXMLTableContext_Impl::EndElement() +{ + SmNodeArray aExpressionArray; + SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + SmNodeStack aReverseStack; + aExpressionArray.resize(rNodeStack.Count()-nElementCount); + + ULONG nRows = rNodeStack.Count()-nElementCount; + USHORT nCols = 0; + + SmStructureNode *pArray; + for (ULONG i=rNodeStack.Count()-nElementCount;i > 0;i--) + { + pArray = (SmStructureNode *)rNodeStack.Pop(); + if (pArray->GetNumSubNodes() == 0) + { + //This is a little tricky, it is possible that there was + //be elements that were not inside a <mtd> pair, in which + //case they will not be in a row, i.e. they will not have + //SubNodes, so we have to wait until here before we can + //resolve the situation. Implicitsurrounding tags are + //surprisingly difficult to get right within this + //architecture + + SmNodeArray aRelationArray; + aRelationArray.resize(1); + aRelationArray[0] = pArray; + SmToken aDummy; + pArray = new SmExpressionNode(aDummy); + pArray->SetSubNodes(aRelationArray); + } + + if (pArray->GetNumSubNodes() > nCols) + nCols = pArray->GetNumSubNodes(); + aReverseStack.Push(pArray); + } + aExpressionArray.resize(nCols*nRows); + ULONG j=0; + while (aReverseStack.Count()) + { + pArray = (SmStructureNode *)aReverseStack.Pop(); + for (USHORT i=0;i<pArray->GetNumSubNodes();i++) + aExpressionArray[j++] = pArray->GetSubNode(i); + } + + SmToken aToken; + aToken.cMathChar = '\0'; + aToken.nGroup = TRGROUP; + aToken.nLevel = 0; + aToken.eType = TMATRIX; + SmMatrixNode *pSNode = new SmMatrixNode(aToken); + pSNode->SetSubNodes(aExpressionArray); + pSNode->SetRowCol(static_cast<USHORT>(nRows),nCols); + rNodeStack.Push(pSNode); +} + +SvXMLImportContext *SmXMLTableRowContext_Impl::CreateChildContext( + sal_uInt16 nPrefix, + const OUString& rLocalName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList) +{ + SvXMLImportContext* pContext = 0L; + + const SvXMLTokenMap& rTokenMap = GetSmImport(). + GetPresTableElemTokenMap(); + switch(rTokenMap.Get(nPrefix, rLocalName)) + { + case XML_TOK_MTD: + pContext = GetSmImport().CreateTableCellContext(nPrefix, + rLocalName, xAttrList); + break; + default: + pContext = SmXMLRowContext_Impl::CreateChildContext(nPrefix, + rLocalName,xAttrList); + break; + } + return pContext; +} + +SvXMLImportContext *SmXMLTableContext_Impl::CreateChildContext( + sal_uInt16 nPrefix, + const OUString& rLocalName, + const uno::Reference<xml::sax::XAttributeList>& xAttrList) +{ + SvXMLImportContext* pContext = 0L; + + const SvXMLTokenMap& rTokenMap = GetSmImport(). + GetPresTableElemTokenMap(); + switch(rTokenMap.Get(nPrefix, rLocalName)) + { + case XML_TOK_MTR: + pContext = GetSmImport().CreateTableRowContext(nPrefix,rLocalName, + xAttrList); + break; + default: + pContext = SmXMLTableRowContext_Impl::CreateChildContext(nPrefix, + rLocalName,xAttrList); + break; + } + return pContext; +} + +void SmXMLMultiScriptsContext_Impl::EndElement() +{ + if (!bHasPrescripts) + MiddleElement(); + + SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + if (rNodeStack.Count()-nElementCount > 1) + { + SmToken aToken; + aToken.cMathChar = '\0'; + aToken.nGroup = 0; + aToken.nLevel = 0; + aToken.eType = TLSUB; + ULONG nFinalCount = rNodeStack.Count()-nElementCount-1; + + SmNodeStack aReverseStack; + while (rNodeStack.Count()-nElementCount) + aReverseStack.Push(rNodeStack.Pop()); + for (ULONG nCount=0;nCount < nFinalCount;nCount+=2) + { + SmSubSupNode *pNode = new SmSubSupNode(aToken); + + // initialize subnodes array + SmNodeArray aSubNodes; + aSubNodes.resize(1 + SUBSUP_NUM_ENTRIES); + for (ULONG i = 1; i < aSubNodes.size(); i++) + aSubNodes[i] = NULL; + + /*On each loop the base and its sub sup pair becomes the + base for the next loop to which the next sub sup pair is + attached, i.e. wheels within wheels*/ + //if (nCount == 0) + aSubNodes[0] = aReverseStack.Pop(); + + SmNode *pScriptNode = aReverseStack.Pop(); + if (pScriptNode->GetToken().aText.Len()) + aSubNodes[LSUB+1] = pScriptNode; + pScriptNode = aReverseStack.Pop(); + if (pScriptNode->GetToken().aText.Len()) + aSubNodes[LSUP+1] = pScriptNode; + + pNode->SetSubNodes(aSubNodes); + aReverseStack.Push(pNode); + } + rNodeStack.Push(aReverseStack.Pop()); + } + +} +void SmXMLActionContext_Impl::EndElement() +{ + /*For now we will just assume that the + selected attribute is one, and then just display + that expression alone, i.e. remove all expect the + first pushed one*/ + + SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + for (ULONG i=rNodeStack.Count()-nElementCount;i > 1;i--) + { + delete rNodeStack.Pop(); + } +} + +SvXMLImportContext *SmXMLImport::CreateContext(sal_uInt16 nPrefix, + const OUString &rLocalName, + const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/) +{ + if ( XML_NAMESPACE_OFFICE == nPrefix ) + { + if ( (IsXMLToken(rLocalName, XML_DOCUMENT) || + IsXMLToken(rLocalName, XML_DOCUMENT_META))) + { + uno::Reference<xml::sax::XDocumentHandler> xDocBuilder( + mxServiceFactory->createInstance( + ::rtl::OUString::createFromAscii( + "com.sun.star.xml.dom.SAXDocumentBuilder")), + uno::UNO_QUERY_THROW); + uno::Reference<document::XDocumentPropertiesSupplier> xDPS( + GetModel(), uno::UNO_QUERY_THROW); + return IsXMLToken(rLocalName, XML_DOCUMENT_META) + ? new SvXMLMetaDocumentContext(*this, + XML_NAMESPACE_OFFICE, rLocalName, + xDPS->getDocumentProperties(), xDocBuilder) + // flat OpenDocument file format -- this has not been tested... + : new SmXMLFlatDocContext_Impl( *this, nPrefix, rLocalName, + xDPS->getDocumentProperties(), xDocBuilder); + } + else + { + return new SmXMLOfficeContext_Impl( *this,nPrefix,rLocalName); + } + } + else + return new SmXMLDocContext_Impl(*this,nPrefix,rLocalName); +} + +SvXMLImportContext *SmXMLImport::CreateRowContext(sal_uInt16 nPrefix, + const OUString &rLocalName, + const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/) +{ + return new SmXMLRowContext_Impl(*this,nPrefix,rLocalName); +} + +SvXMLImportContext *SmXMLImport::CreateTextContext(sal_uInt16 nPrefix, + const OUString &rLocalName, + const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/) +{ + return new SmXMLTextContext_Impl(*this,nPrefix,rLocalName); +} + +SvXMLImportContext *SmXMLImport::CreateAnnotationContext(sal_uInt16 nPrefix, + const OUString &rLocalName, + const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/) +{ + return new SmXMLAnnotationContext_Impl(*this,nPrefix,rLocalName); +} + +SvXMLImportContext *SmXMLImport::CreateStringContext(sal_uInt16 nPrefix, + const OUString &rLocalName, + const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/) +{ + return new SmXMLStringContext_Impl(*this,nPrefix,rLocalName); +} + +SvXMLImportContext *SmXMLImport::CreateNumberContext(sal_uInt16 nPrefix, + const OUString &rLocalName, + const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/) +{ + return new SmXMLNumberContext_Impl(*this,nPrefix,rLocalName); +} + +SvXMLImportContext *SmXMLImport::CreateIdentifierContext(sal_uInt16 nPrefix, + const OUString &rLocalName, + const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/) +{ + return new SmXMLIdentifierContext_Impl(*this,nPrefix,rLocalName); +} + +SvXMLImportContext *SmXMLImport::CreateOperatorContext(sal_uInt16 nPrefix, + const OUString &rLocalName, + const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/) +{ + return new SmXMLOperatorContext_Impl(*this,nPrefix,rLocalName); +} + +SvXMLImportContext *SmXMLImport::CreateSpaceContext(sal_uInt16 nPrefix, + const OUString &rLocalName, + const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/) +{ + return new SmXMLSpaceContext_Impl(*this,nPrefix,rLocalName); +} + + +SvXMLImportContext *SmXMLImport::CreateFracContext(sal_uInt16 nPrefix, + const OUString &rLocalName, + const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/) +{ + return new SmXMLFracContext_Impl(*this,nPrefix,rLocalName); +} + +SvXMLImportContext *SmXMLImport::CreateSqrtContext(sal_uInt16 nPrefix, + const OUString &rLocalName, + const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/) +{ + return new SmXMLSqrtContext_Impl(*this,nPrefix,rLocalName); +} + +SvXMLImportContext *SmXMLImport::CreateRootContext(sal_uInt16 nPrefix, + const OUString &rLocalName, + const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/) +{ + return new SmXMLRootContext_Impl(*this,nPrefix,rLocalName); +} + +SvXMLImportContext *SmXMLImport::CreateStyleContext(sal_uInt16 nPrefix, + const OUString &rLocalName, + const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/) +{ + return new SmXMLStyleContext_Impl(*this,nPrefix,rLocalName); +} + +SvXMLImportContext *SmXMLImport::CreatePaddedContext(sal_uInt16 nPrefix, + const OUString &rLocalName, + const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/) +{ + return new SmXMLPaddedContext_Impl(*this,nPrefix,rLocalName); +} + +SvXMLImportContext *SmXMLImport::CreatePhantomContext(sal_uInt16 nPrefix, + const OUString &rLocalName, + const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/) +{ + return new SmXMLPhantomContext_Impl(*this,nPrefix,rLocalName); +} + +SvXMLImportContext *SmXMLImport::CreateFencedContext(sal_uInt16 nPrefix, + const OUString &rLocalName, + const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/) +{ + return new SmXMLFencedContext_Impl(*this,nPrefix,rLocalName); +} + +SvXMLImportContext *SmXMLImport::CreateErrorContext(sal_uInt16 nPrefix, + const OUString &rLocalName, + const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/) +{ + return new SmXMLErrorContext_Impl(*this,nPrefix,rLocalName); +} + +SvXMLImportContext *SmXMLImport::CreateSubContext(sal_uInt16 nPrefix, + const OUString &rLocalName, + const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/) +{ + return new SmXMLSubContext_Impl(*this,nPrefix,rLocalName); +} + +SvXMLImportContext *SmXMLImport::CreateSubSupContext(sal_uInt16 nPrefix, + const OUString &rLocalName, + const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/) +{ + return new SmXMLSubSupContext_Impl(*this,nPrefix,rLocalName); +} + +SvXMLImportContext *SmXMLImport::CreateSupContext(sal_uInt16 nPrefix, + const OUString &rLocalName, + const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/) +{ + return new SmXMLSupContext_Impl(*this,nPrefix,rLocalName); +} + +SvXMLImportContext *SmXMLImport::CreateUnderContext(sal_uInt16 nPrefix, + const OUString &rLocalName, + const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/) +{ + return new SmXMLUnderContext_Impl(*this,nPrefix,rLocalName); +} + +SvXMLImportContext *SmXMLImport::CreateOverContext(sal_uInt16 nPrefix, + const OUString &rLocalName, + const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/) +{ + return new SmXMLOverContext_Impl(*this,nPrefix,rLocalName); +} + +SvXMLImportContext *SmXMLImport::CreateUnderOverContext(sal_uInt16 nPrefix, + const OUString &rLocalName, + const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/) +{ + return new SmXMLUnderOverContext_Impl(*this,nPrefix,rLocalName); +} + +SvXMLImportContext *SmXMLImport::CreateMultiScriptsContext(sal_uInt16 nPrefix, + const OUString &rLocalName, + const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/) +{ + return new SmXMLMultiScriptsContext_Impl(*this,nPrefix,rLocalName); +} + +SvXMLImportContext *SmXMLImport::CreateTableContext(sal_uInt16 nPrefix, + const OUString &rLocalName, + const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/) +{ + return new SmXMLTableContext_Impl(*this,nPrefix,rLocalName); +} +SvXMLImportContext *SmXMLImport::CreateTableRowContext(sal_uInt16 nPrefix, + const OUString &rLocalName, + const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/) +{ + return new SmXMLTableRowContext_Impl(*this,nPrefix,rLocalName); +} +SvXMLImportContext *SmXMLImport::CreateTableCellContext(sal_uInt16 nPrefix, + const OUString &rLocalName, + const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/) +{ + return new SmXMLTableCellContext_Impl(*this,nPrefix,rLocalName); +} + +SvXMLImportContext *SmXMLImport::CreateNoneContext(sal_uInt16 nPrefix, + const OUString &rLocalName, + const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/) +{ + return new SmXMLNoneContext_Impl(*this,nPrefix,rLocalName); +} + +SvXMLImportContext *SmXMLImport::CreatePrescriptsContext(sal_uInt16 nPrefix, + const OUString &rLocalName, + const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/) +{ + return new SmXMLPrescriptsContext_Impl(*this,nPrefix,rLocalName); +} + +SvXMLImportContext *SmXMLImport::CreateAlignGroupContext(sal_uInt16 nPrefix, + const OUString &rLocalName, + const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/) +{ + return new SmXMLAlignGroupContext_Impl(*this,nPrefix,rLocalName); +} + +SvXMLImportContext *SmXMLImport::CreateActionContext(sal_uInt16 nPrefix, + const OUString &rLocalName, + const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/) +{ + return new SmXMLActionContext_Impl(*this,nPrefix,rLocalName); +} + +SmXMLImport::~SmXMLImport() throw () +{ + delete pPresLayoutElemTokenMap; + delete pPresElemTokenMap; + delete pPresScriptEmptyElemTokenMap; + delete pPresTableElemTokenMap; + delete pPresLayoutAttrTokenMap; + delete pFencedAttrTokenMap; + delete pColorTokenMap; + delete pOperatorAttrTokenMap; + delete pAnnotationAttrTokenMap; +} + +void SmXMLImport::SetViewSettings(const Sequence<PropertyValue>& aViewProps) +{ + uno::Reference <frame::XModel> xModel = GetModel(); + if ( !xModel.is() ) + return; + + uno::Reference <lang::XUnoTunnel> xTunnel; + xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY); + SmModel *pModel = reinterpret_cast<SmModel *> + (xTunnel->getSomething(SmModel::getUnoTunnelId())); + + if ( !pModel ) + return; + + SmDocShell *pDocShell = + static_cast<SmDocShell*>(pModel->GetObjectShell()); + if ( !pDocShell ) + return; + + Rectangle aRect( pDocShell->GetVisArea() ); + + sal_Int32 nCount = aViewProps.getLength(); + const PropertyValue *pValue = aViewProps.getConstArray(); + + long nTmp = 0; + //sal_Bool bShowDeletes = sal_False, bShowInserts = sal_False, bShowFooter = sal_False, bShowHeader = sal_False; + + for (sal_Int32 i = 0; i < nCount ; i++) + { + if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ViewAreaTop" ) ) ) + { + pValue->Value >>= nTmp; + aRect.setY( nTmp ); + } + else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ViewAreaLeft" ) ) ) + { + pValue->Value >>= nTmp; + aRect.setX( nTmp ); + } + else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ViewAreaWidth" ) ) ) + { + pValue->Value >>= nTmp; + Size aSize( aRect.GetSize() ); + aSize.Width() = nTmp; + aRect.SetSize( aSize ); + } + else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ViewAreaHeight" ) ) ) + { + pValue->Value >>= nTmp; + Size aSize( aRect.GetSize() ); + aSize.Height() = nTmp; + aRect.SetSize( aSize ); + } + pValue++; + } + + pDocShell->SetVisArea ( aRect ); +} + +void SmXMLImport::SetConfigurationSettings(const Sequence<PropertyValue>& aConfProps) +{ + uno::Reference < XPropertySet > xProps ( GetModel(), UNO_QUERY ); + if ( xProps.is() ) + { + Reference < XPropertySetInfo > xInfo ( xProps->getPropertySetInfo() ); + if (xInfo.is() ) + { + sal_Int32 nCount = aConfProps.getLength(); + const PropertyValue* pValues = aConfProps.getConstArray(); + + const OUString sFormula ( RTL_CONSTASCII_USTRINGPARAM ( "Formula" ) ); + const OUString sBasicLibraries ( RTL_CONSTASCII_USTRINGPARAM ( "BasicLibraries" ) ); + const OUString sDialogLibraries ( RTL_CONSTASCII_USTRINGPARAM ( "DialogLibraries" ) ); + while ( nCount-- ) + { + if (pValues->Name != sFormula && + pValues->Name != sBasicLibraries && + pValues->Name != sDialogLibraries) + { + try + { + if ( xInfo->hasPropertyByName( pValues->Name ) ) + xProps->setPropertyValue( pValues->Name, pValues->Value ); + } + catch( Exception& ) + { + DBG_ERROR( "SmXMLImport::SetConfigurationSettings: Exception!" ); + } + } + + pValues++; + } + } + } +} + + +//////////////////////////////////////////////////////////// + + diff --git a/starmath/source/mathmlimport.hxx b/starmath/source/mathmlimport.hxx index ed46efa823fc..22c2017c61b1 100644 --- a/starmath/source/mathmlimport.hxx +++ b/starmath/source/mathmlimport.hxx @@ -1,350 +1,347 @@ -/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: x $
- * $Revision: 1.00 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef _MATHMLIMPORT_HXX_
-#define _MATHMLIMPORT_HXX_
-
-#include <xmloff/xmlimp.hxx>
-#include <xmloff/xmlexp.hxx>
-#include <xmloff/DocumentSettingsContext.hxx>
-#include <xmloff/xmltoken.hxx>
-
-#include <node.hxx>
-
-class SfxMedium;
-namespace com { namespace sun { namespace star {
- namespace io {
- class XInputStream;
- class XOutputStream; }
- namespace beans {
- class XPropertySet; }
-} } }
-
-////////////////////////////////////////////////////////////
-
-class SmXMLImportWrapper
-{
- com::sun::star::uno::Reference<com::sun::star::frame::XModel> xModel;
-
-public:
- SmXMLImportWrapper(com::sun::star::uno::Reference<com::sun::star::frame::XModel> &rRef)
- : xModel(rRef) {}
-
- ULONG Import(SfxMedium &rMedium);
-
- ULONG ReadThroughComponent(
- ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > xInputStream,
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xModelComponent,
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rFactory,
- ::com::sun::star::uno::Reference<
- ::com::sun::star::beans::XPropertySet > & rPropSet,
- const sal_Char* pFilterName,
- sal_Bool bEncrypted );
-
- ULONG ReadThroughComponent(
- const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage,
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xModelComponent,
- const sal_Char* pStreamName,
- const sal_Char* pCompatibilityStreamName,
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rFactory,
- ::com::sun::star::uno::Reference<
- ::com::sun::star::beans::XPropertySet > & rPropSet,
- const sal_Char* pFilterName );
-};
-
-////////////////////////////////////////////////////////////
-
-class SmXMLImport : public SvXMLImport
-{
- SvXMLTokenMap *pPresLayoutElemTokenMap;
- SvXMLTokenMap *pPresLayoutAttrTokenMap;
- SvXMLTokenMap *pFencedAttrTokenMap;
- SvXMLTokenMap *pOperatorAttrTokenMap;
- SvXMLTokenMap *pAnnotationAttrTokenMap;
- SvXMLTokenMap *pPresElemTokenMap;
- SvXMLTokenMap *pPresScriptEmptyElemTokenMap;
- SvXMLTokenMap *pPresTableElemTokenMap;
- SvXMLTokenMap *pColorTokenMap;
-
- SmNodeStack aNodeStack;
- sal_Bool bSuccess;
- String aText;
-
-public:
- // #110680#
- SmXMLImport(
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
- sal_uInt16 nImportFlags=IMPORT_ALL);
- virtual ~SmXMLImport() throw ();
-
- // XServiceInfo (override parent method)
- ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
-
- // XUnoTunnel
- sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw(::com::sun::star::uno::RuntimeException);
- static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId() throw();
-
- void SAL_CALL endDocument(void)
- throw( ::com::sun::star::xml::sax::SAXException,
- ::com::sun::star::uno::RuntimeException );
-
- SvXMLImportContext *CreateContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateMathContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateRowContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateFracContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateNumberContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateTextContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateAnnotationContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateStringContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateIdentifierContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateOperatorContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateSpaceContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateSqrtContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateRootContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateStyleContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreatePaddedContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreatePhantomContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateFencedContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateErrorContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateSubContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateSupContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateSubSupContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateUnderContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateOverContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateUnderOverContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateMultiScriptsContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateNoneContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreatePrescriptsContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateTableContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateTableRowContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateTableCellContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateAlignGroupContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateActionContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
-
- const SvXMLTokenMap &GetPresLayoutElemTokenMap();
- const SvXMLTokenMap &GetPresLayoutAttrTokenMap();
- const SvXMLTokenMap &GetFencedAttrTokenMap();
- const SvXMLTokenMap &GetOperatorAttrTokenMap();
- const SvXMLTokenMap &GetAnnotationAttrTokenMap();
- const SvXMLTokenMap &GetPresElemTokenMap();
- const SvXMLTokenMap &GetPresScriptEmptyElemTokenMap();
- const SvXMLTokenMap &GetPresTableElemTokenMap();
- const SvXMLTokenMap &GetColorTokenMap();
-
- SmNodeStack & GetNodeStack() {return aNodeStack;}
- SmNode *GetTree() { return aNodeStack.Pop();}
- sal_Bool GetSuccess() { return bSuccess; }
- String &GetText() { return aText;}
-
- virtual void SetViewSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aViewProps);
- virtual void SetConfigurationSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aViewProps);
-};
-
-////////////////////////////////////////////////////////////
-
-enum SmXMLMathElemTokenMap
-{
- XML_TOK_MATH
-};
-
-enum SmXMLPresLayoutElemTokenMap
-{
- XML_TOK_SEMANTICS,
- XML_TOK_MSTYLE,
- XML_TOK_MERROR,
- XML_TOK_MPHANTOM,
- XML_TOK_MROW,
- XML_TOK_MFRAC,
- XML_TOK_MSQRT,
- XML_TOK_MROOT,
- XML_TOK_MSUB,
- XML_TOK_MSUP,
- XML_TOK_MSUBSUP,
- XML_TOK_MMULTISCRIPTS,
- XML_TOK_MUNDER,
- XML_TOK_MOVER,
- XML_TOK_MUNDEROVER,
- XML_TOK_MTABLE,
- XML_TOK_MACTION,
- XML_TOK_MFENCED,
- XML_TOK_MPADDED
-};
-
-enum SmXMLPresLayoutAttrTokenMap
-{
- XML_TOK_FONTWEIGHT,
- XML_TOK_FONTSTYLE,
- XML_TOK_FONTSIZE,
- XML_TOK_FONTFAMILY,
- XML_TOK_COLOR
-};
-
-
-enum SmXMLFencedAttrTokenMap
-{
- XML_TOK_OPEN,
- XML_TOK_CLOSE
-};
-
-
-enum SmXMLPresTableElemTokenMap
-{
- XML_TOK_MTR,
- XML_TOK_MTD
-};
-
-enum SmXMLPresElemTokenMap
-{
- XML_TOK_ANNOTATION,
- XML_TOK_MI,
- XML_TOK_MN,
- XML_TOK_MO,
- XML_TOK_MTEXT,
- XML_TOK_MSPACE,
- XML_TOK_MS,
- XML_TOK_MALIGNGROUP
-};
-
-enum SmXMLPresScriptEmptyElemTokenMap
-{
- XML_TOK_MPRESCRIPTS,
- XML_TOK_NONE
-};
-
-enum SmXMLOperatorAttrTokenMap
-{
- XML_TOK_STRETCHY
-};
-
-enum SmXMLAnnotationAttrTokenMap
-{
- XML_TOK_ENCODING
-};
-
-////////////////////////////////////////////////////////////
-
-#endif
-
+/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _MATHMLIMPORT_HXX_ +#define _MATHMLIMPORT_HXX_ + +#include <xmloff/xmlimp.hxx> +#include <xmloff/xmlexp.hxx> +#include <xmloff/DocumentSettingsContext.hxx> +#include <xmloff/xmltoken.hxx> + +#include <node.hxx> + +class SfxMedium; +namespace com { namespace sun { namespace star { + namespace io { + class XInputStream; + class XOutputStream; } + namespace beans { + class XPropertySet; } +} } } + +//////////////////////////////////////////////////////////// + +class SmXMLImportWrapper +{ + com::sun::star::uno::Reference<com::sun::star::frame::XModel> xModel; + +public: + SmXMLImportWrapper(com::sun::star::uno::Reference<com::sun::star::frame::XModel> &rRef) + : xModel(rRef) {} + + ULONG Import(SfxMedium &rMedium); + + ULONG ReadThroughComponent( + ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > xInputStream, + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xModelComponent, + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rFactory, + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > & rPropSet, + const sal_Char* pFilterName, + sal_Bool bEncrypted ); + + ULONG ReadThroughComponent( + const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage, + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xModelComponent, + const sal_Char* pStreamName, + const sal_Char* pCompatibilityStreamName, + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rFactory, + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > & rPropSet, + const sal_Char* pFilterName ); +}; + +//////////////////////////////////////////////////////////// + +class SmXMLImport : public SvXMLImport +{ + SvXMLTokenMap *pPresLayoutElemTokenMap; + SvXMLTokenMap *pPresLayoutAttrTokenMap; + SvXMLTokenMap *pFencedAttrTokenMap; + SvXMLTokenMap *pOperatorAttrTokenMap; + SvXMLTokenMap *pAnnotationAttrTokenMap; + SvXMLTokenMap *pPresElemTokenMap; + SvXMLTokenMap *pPresScriptEmptyElemTokenMap; + SvXMLTokenMap *pPresTableElemTokenMap; + SvXMLTokenMap *pColorTokenMap; + + SmNodeStack aNodeStack; + sal_Bool bSuccess; + String aText; + +public: + // #110680# + SmXMLImport( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory, + sal_uInt16 nImportFlags=IMPORT_ALL); + virtual ~SmXMLImport() throw (); + + // XServiceInfo (override parent method) + ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ); + + // XUnoTunnel + sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw(::com::sun::star::uno::RuntimeException); + static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId() throw(); + + void SAL_CALL endDocument(void) + throw( ::com::sun::star::xml::sax::SAXException, + ::com::sun::star::uno::RuntimeException ); + + SvXMLImportContext *CreateContext(sal_uInt16 nPrefix, + const rtl::OUString &rLocalName, + const com::sun::star::uno::Reference < + com::sun::star::xml::sax::XAttributeList> &xAttrList); + SvXMLImportContext *CreateMathContext(sal_uInt16 nPrefix, + const rtl::OUString &rLocalName, + const com::sun::star::uno::Reference < + com::sun::star::xml::sax::XAttributeList> &xAttrList); + SvXMLImportContext *CreateRowContext(sal_uInt16 nPrefix, + const rtl::OUString &rLocalName, + const com::sun::star::uno::Reference < + com::sun::star::xml::sax::XAttributeList> &xAttrList); + SvXMLImportContext *CreateFracContext(sal_uInt16 nPrefix, + const rtl::OUString &rLocalName, + const com::sun::star::uno::Reference < + com::sun::star::xml::sax::XAttributeList> &xAttrList); + SvXMLImportContext *CreateNumberContext(sal_uInt16 nPrefix, + const rtl::OUString &rLocalName, + const com::sun::star::uno::Reference < + com::sun::star::xml::sax::XAttributeList> &xAttrList); + SvXMLImportContext *CreateTextContext(sal_uInt16 nPrefix, + const rtl::OUString &rLocalName, + const com::sun::star::uno::Reference < + com::sun::star::xml::sax::XAttributeList> &xAttrList); + SvXMLImportContext *CreateAnnotationContext(sal_uInt16 nPrefix, + const rtl::OUString &rLocalName, + const com::sun::star::uno::Reference < + com::sun::star::xml::sax::XAttributeList> &xAttrList); + SvXMLImportContext *CreateStringContext(sal_uInt16 nPrefix, + const rtl::OUString &rLocalName, + const com::sun::star::uno::Reference < + com::sun::star::xml::sax::XAttributeList> &xAttrList); + SvXMLImportContext *CreateIdentifierContext(sal_uInt16 nPrefix, + const rtl::OUString &rLocalName, + const com::sun::star::uno::Reference < + com::sun::star::xml::sax::XAttributeList> &xAttrList); + SvXMLImportContext *CreateOperatorContext(sal_uInt16 nPrefix, + const rtl::OUString &rLocalName, + const com::sun::star::uno::Reference < + com::sun::star::xml::sax::XAttributeList> &xAttrList); + SvXMLImportContext *CreateSpaceContext(sal_uInt16 nPrefix, + const rtl::OUString &rLocalName, + const com::sun::star::uno::Reference < + com::sun::star::xml::sax::XAttributeList> &xAttrList); + SvXMLImportContext *CreateSqrtContext(sal_uInt16 nPrefix, + const rtl::OUString &rLocalName, + const com::sun::star::uno::Reference < + com::sun::star::xml::sax::XAttributeList> &xAttrList); + SvXMLImportContext *CreateRootContext(sal_uInt16 nPrefix, + const rtl::OUString &rLocalName, + const com::sun::star::uno::Reference < + com::sun::star::xml::sax::XAttributeList> &xAttrList); + SvXMLImportContext *CreateStyleContext(sal_uInt16 nPrefix, + const rtl::OUString &rLocalName, + const com::sun::star::uno::Reference < + com::sun::star::xml::sax::XAttributeList> &xAttrList); + SvXMLImportContext *CreatePaddedContext(sal_uInt16 nPrefix, + const rtl::OUString &rLocalName, + const com::sun::star::uno::Reference < + com::sun::star::xml::sax::XAttributeList> &xAttrList); + SvXMLImportContext *CreatePhantomContext(sal_uInt16 nPrefix, + const rtl::OUString &rLocalName, + const com::sun::star::uno::Reference < + com::sun::star::xml::sax::XAttributeList> &xAttrList); + SvXMLImportContext *CreateFencedContext(sal_uInt16 nPrefix, + const rtl::OUString &rLocalName, + const com::sun::star::uno::Reference < + com::sun::star::xml::sax::XAttributeList> &xAttrList); + SvXMLImportContext *CreateErrorContext(sal_uInt16 nPrefix, + const rtl::OUString &rLocalName, + const com::sun::star::uno::Reference < + com::sun::star::xml::sax::XAttributeList> &xAttrList); + SvXMLImportContext *CreateSubContext(sal_uInt16 nPrefix, + const rtl::OUString &rLocalName, + const com::sun::star::uno::Reference < + com::sun::star::xml::sax::XAttributeList> &xAttrList); + SvXMLImportContext *CreateSupContext(sal_uInt16 nPrefix, + const rtl::OUString &rLocalName, + const com::sun::star::uno::Reference < + com::sun::star::xml::sax::XAttributeList> &xAttrList); + SvXMLImportContext *CreateSubSupContext(sal_uInt16 nPrefix, + const rtl::OUString &rLocalName, + const com::sun::star::uno::Reference < + com::sun::star::xml::sax::XAttributeList> &xAttrList); + SvXMLImportContext *CreateUnderContext(sal_uInt16 nPrefix, + const rtl::OUString &rLocalName, + const com::sun::star::uno::Reference < + com::sun::star::xml::sax::XAttributeList> &xAttrList); + SvXMLImportContext *CreateOverContext(sal_uInt16 nPrefix, + const rtl::OUString &rLocalName, + const com::sun::star::uno::Reference < + com::sun::star::xml::sax::XAttributeList> &xAttrList); + SvXMLImportContext *CreateUnderOverContext(sal_uInt16 nPrefix, + const rtl::OUString &rLocalName, + const com::sun::star::uno::Reference < + com::sun::star::xml::sax::XAttributeList> &xAttrList); + SvXMLImportContext *CreateMultiScriptsContext(sal_uInt16 nPrefix, + const rtl::OUString &rLocalName, + const com::sun::star::uno::Reference < + com::sun::star::xml::sax::XAttributeList> &xAttrList); + SvXMLImportContext *CreateNoneContext(sal_uInt16 nPrefix, + const rtl::OUString &rLocalName, + const com::sun::star::uno::Reference < + com::sun::star::xml::sax::XAttributeList> &xAttrList); + SvXMLImportContext *CreatePrescriptsContext(sal_uInt16 nPrefix, + const rtl::OUString &rLocalName, + const com::sun::star::uno::Reference < + com::sun::star::xml::sax::XAttributeList> &xAttrList); + SvXMLImportContext *CreateTableContext(sal_uInt16 nPrefix, + const rtl::OUString &rLocalName, + const com::sun::star::uno::Reference < + com::sun::star::xml::sax::XAttributeList> &xAttrList); + SvXMLImportContext *CreateTableRowContext(sal_uInt16 nPrefix, + const rtl::OUString &rLocalName, + const com::sun::star::uno::Reference < + com::sun::star::xml::sax::XAttributeList> &xAttrList); + SvXMLImportContext *CreateTableCellContext(sal_uInt16 nPrefix, + const rtl::OUString &rLocalName, + const com::sun::star::uno::Reference < + com::sun::star::xml::sax::XAttributeList> &xAttrList); + SvXMLImportContext *CreateAlignGroupContext(sal_uInt16 nPrefix, + const rtl::OUString &rLocalName, + const com::sun::star::uno::Reference < + com::sun::star::xml::sax::XAttributeList> &xAttrList); + SvXMLImportContext *CreateActionContext(sal_uInt16 nPrefix, + const rtl::OUString &rLocalName, + const com::sun::star::uno::Reference < + com::sun::star::xml::sax::XAttributeList> &xAttrList); + + const SvXMLTokenMap &GetPresLayoutElemTokenMap(); + const SvXMLTokenMap &GetPresLayoutAttrTokenMap(); + const SvXMLTokenMap &GetFencedAttrTokenMap(); + const SvXMLTokenMap &GetOperatorAttrTokenMap(); + const SvXMLTokenMap &GetAnnotationAttrTokenMap(); + const SvXMLTokenMap &GetPresElemTokenMap(); + const SvXMLTokenMap &GetPresScriptEmptyElemTokenMap(); + const SvXMLTokenMap &GetPresTableElemTokenMap(); + const SvXMLTokenMap &GetColorTokenMap(); + + SmNodeStack & GetNodeStack() {return aNodeStack;} + SmNode *GetTree() { return aNodeStack.Pop();} + sal_Bool GetSuccess() { return bSuccess; } + String &GetText() { return aText;} + + virtual void SetViewSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aViewProps); + virtual void SetConfigurationSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aViewProps); +}; + +//////////////////////////////////////////////////////////// + +enum SmXMLMathElemTokenMap +{ + XML_TOK_MATH +}; + +enum SmXMLPresLayoutElemTokenMap +{ + XML_TOK_SEMANTICS, + XML_TOK_MSTYLE, + XML_TOK_MERROR, + XML_TOK_MPHANTOM, + XML_TOK_MROW, + XML_TOK_MFRAC, + XML_TOK_MSQRT, + XML_TOK_MROOT, + XML_TOK_MSUB, + XML_TOK_MSUP, + XML_TOK_MSUBSUP, + XML_TOK_MMULTISCRIPTS, + XML_TOK_MUNDER, + XML_TOK_MOVER, + XML_TOK_MUNDEROVER, + XML_TOK_MTABLE, + XML_TOK_MACTION, + XML_TOK_MFENCED, + XML_TOK_MPADDED +}; + +enum SmXMLPresLayoutAttrTokenMap +{ + XML_TOK_FONTWEIGHT, + XML_TOK_FONTSTYLE, + XML_TOK_FONTSIZE, + XML_TOK_FONTFAMILY, + XML_TOK_COLOR +}; + + +enum SmXMLFencedAttrTokenMap +{ + XML_TOK_OPEN, + XML_TOK_CLOSE +}; + + +enum SmXMLPresTableElemTokenMap +{ + XML_TOK_MTR, + XML_TOK_MTD +}; + +enum SmXMLPresElemTokenMap +{ + XML_TOK_ANNOTATION, + XML_TOK_MI, + XML_TOK_MN, + XML_TOK_MO, + XML_TOK_MTEXT, + XML_TOK_MSPACE, + XML_TOK_MS, + XML_TOK_MALIGNGROUP +}; + +enum SmXMLPresScriptEmptyElemTokenMap +{ + XML_TOK_MPRESCRIPTS, + XML_TOK_NONE +}; + +enum SmXMLOperatorAttrTokenMap +{ + XML_TOK_STRETCHY +}; + +enum SmXMLAnnotationAttrTokenMap +{ + XML_TOK_ENCODING +}; + +//////////////////////////////////////////////////////////// + +#endif + diff --git a/starmath/source/mathtype.cxx b/starmath/source/mathtype.cxx index 3f122d5c3e0a..f3e2f99d99d2 100644 --- a/starmath/source/mathtype.cxx +++ b/starmath/source/mathtype.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: mathtype.cxx,v $ - * $Revision: 1.40 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/starmath/source/mathtype.hxx b/starmath/source/mathtype.hxx index 31294e90bd21..510011d81788 100644 --- a/starmath/source/mathtype.hxx +++ b/starmath/source/mathtype.hxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: mathtype.hxx,v $ - * $Revision: 1.12 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/starmath/source/menu_tmpl.src b/starmath/source/menu_tmpl.src index 8fe55ea058b6..c6eeeb60b7cd 100644 --- a/starmath/source/menu_tmpl.src +++ b/starmath/source/menu_tmpl.src @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: menu_tmpl.src,v $ - * $Revision: 1.4 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx index ad3987549c0f..722df5a1d502 100644 --- a/starmath/source/node.cxx +++ b/starmath/source/node.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: node.cxx,v $ - * $Revision: 1.42 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -1651,7 +1648,7 @@ void SmBraceNode::Arrange(const OutputDevice &rDev, const SmFormat &rFormat) "Sm : unterschiedliche Fontgroessen"); aTmpSize.Width() = Min((long) nBraceHeight * 60L / 100L, rFormat.GetBaseSize().Height() * 3L / 2L); - // correction factor since change from StarMath to StarSymbol font + // correction factor since change from StarMath to OpenSymbol font // because of the different font width in the FontMetric aTmpSize.Width() *= 182; aTmpSize.Width() /= 267; @@ -2694,7 +2691,7 @@ void SmMathSymbolNode::Prepare(const SmFormat &rFormat, const SmDocShell &rDocSh DBG_ASSERT(GetFont().GetCharSet() == RTL_TEXTENCODING_SYMBOL || GetFont().GetCharSet() == RTL_TEXTENCODING_UNICODE, - "incorrect charset for character from StarMath/StarSymbol font"); + "incorrect charset for character from StarMath/OpenSymbol font"); Flags() |= FLG_FONT | FLG_ITALIC; }; diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx index 83662e50b123..1955b0553b62 100644 --- a/starmath/source/parse.cxx +++ b/starmath/source/parse.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: parse.cxx,v $ - * $Revision: 1.35 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -39,8 +36,8 @@ #include <com/sun/star/i18n/UnicodeType.hpp> #include <i18npool/lang.h> #include <unotools/charclass.hxx> -#include <svx/unolingu.hxx> -#include <svtools/syslocale.hxx> +#include <editeng/unolingu.hxx> +#include <unotools/syslocale.hxx> #include "parse.hxx" #ifndef _STARMATH_HRC #include "starmath.hrc" diff --git a/starmath/source/rect.cxx b/starmath/source/rect.cxx index 0718be8ffd37..02df2ddf060e 100644 --- a/starmath/source/rect.cxx +++ b/starmath/source/rect.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: rect.cxx,v $ - * $Revision: 1.21 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -150,8 +147,7 @@ void SmRect::BuildRect(const OutputDevice &rDev, const SmFormat *pFormat, aSize = Size(rDev.GetTextWidth(rText), rDev.GetTextHeight()); const FontMetric aFM (rDev.GetFontMetric()); - BOOL bIsMath = aFM.GetName().EqualsIgnoreCaseAscii( FONTNAME_MATH ) || - aFM.GetName().EqualsIgnoreCaseAscii( FONTNAME_MATH2 ); + BOOL bIsMath = aFM.GetName().EqualsIgnoreCaseAscii( FONTNAME_MATH ); BOOL bAllowSmaller = bIsMath && !SmIsMathAlpha(rText); const long nFontHeight = rDev.GetFont().GetSize().Height(); diff --git a/starmath/source/register.cxx b/starmath/source/register.cxx index 717382c49c25..0983d0a86ee4 100644 --- a/starmath/source/register.cxx +++ b/starmath/source/register.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: register.cxx,v $ - * $Revision: 1.14 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/starmath/source/smdetect.cxx b/starmath/source/smdetect.cxx index f65b7fcdc764..aef4df112431 100644 --- a/starmath/source/smdetect.cxx +++ b/starmath/source/smdetect.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: smdetect.cxx,v $ - * $Revision: 1.11 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -60,10 +57,10 @@ #include <rtl/ustring.h> #include <rtl/logfile.hxx> -#include <svtools/itemset.hxx> +#include <svl/itemset.hxx> #include <vcl/window.hxx> -#include <svtools/eitem.hxx> -#include <svtools/stritem.hxx> +#include <svl/eitem.hxx> +#include <svl/stritem.hxx> #include <tools/urlobj.hxx> #include <vos/mutex.hxx> #include <svtools/sfxecode.hxx> diff --git a/starmath/source/smdetect.hxx b/starmath/source/smdetect.hxx index f004f008ef45..b9302260d8bd 100644 --- a/starmath/source/smdetect.hxx +++ b/starmath/source/smdetect.hxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: smdetect.hxx,v $ - * $Revision: 1.4 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/starmath/source/smdll.cxx b/starmath/source/smdll.cxx index 7b9e79a9cf41..63a86d520d9e 100644 --- a/starmath/source/smdll.cxx +++ b/starmath/source/smdll.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: smdll.cxx,v $ - * $Revision: 1.13 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/starmath/source/smmod.cxx b/starmath/source/smmod.cxx index 20cfc284d006..451bb8664bc5 100644 --- a/starmath/source/smmod.cxx +++ b/starmath/source/smmod.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: smmod.cxx,v $ - * $Revision: 1.22 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -37,7 +34,7 @@ #include <sfx2/msg.hxx> #include <sfx2/app.hxx> #include <sfx2/objface.hxx> -#include <svtools/whiter.hxx> +#include <svl/whiter.hxx> #include <sfx2/request.hxx> #include <sfx2/sfx.hrc> #include <sfx2/viewsh.hxx> @@ -47,7 +44,7 @@ #endif #include <vcl/msgbox.hxx> #include <vcl/virdev.hxx> -#include <svtools/syslocale.hxx> +#include <unotools/syslocale.hxx> #include <tools/rtti.hxx> #include "smmod.hxx" #include "symbol.hxx" @@ -251,6 +248,8 @@ SmModule::SmModule(SfxObjectFactory* pObjFact) : SmModule::~SmModule() { delete pConfig; + if (pColorConfig) + pColorConfig->RemoveListener(this); delete pColorConfig; delete pLocSymbolData; delete pSysLocale; @@ -295,19 +294,14 @@ svtools::ColorConfig & SmModule::GetColorConfig() { pColorConfig = new svtools::ColorConfig; ApplyColorConfigValues( *pColorConfig ); - StartListening( *pColorConfig ); + pColorConfig->AddListener(this); } return *pColorConfig; } -void SmModule::Notify( SfxBroadcaster & /*rBC*/, const SfxHint &rHint ) +void SmModule::ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 ) { - if (rHint.ISA(SfxSimpleHint)) - { - ULONG nHintId = ((SfxSimpleHint&)rHint).GetId(); - if (SFX_HINT_COLORS_CHANGED == nHintId) - ApplyColorConfigValues(*pColorConfig); - } + ApplyColorConfigValues(*pColorConfig); } SmConfig * SmModule::GetConfig() diff --git a/starmath/source/smres.src b/starmath/source/smres.src index eee43aace130..64891a95daf9 100644 --- a/starmath/source/smres.src +++ b/starmath/source/smres.src @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: smres.src,v $ - * $Revision: 1.118 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -114,14 +111,12 @@ ModalDialog RID_FONTSIZEDIALOG SVLook = TRUE ; HelpID = SID_FONTSIZE ; Size = MAP_APPFONT ( 171 , 120 ) ; - /* ### ACHTUNG: Neuer Text in Resource? Schriftgren : Schriftgren */ Text [ en-US ] = "Font Sizes" ; FixedText 1 { Left = TRUE ; Pos = MAP_APPFONT ( 12 , 7 ) ; Size = MAP_APPFONT ( 40 , 10 ) ; - /* ### ACHTUNG: Neuer Text in Resource? ~Basisgre: : ~Basisgre: */ Text [ en-US ] = "Base ~size"; }; MetricField 1 @@ -246,7 +241,6 @@ ModalDialog RID_FONTSIZEDIALOG { Pos = MAP_APPFONT ( 6 , 24 ) ; Size = MAP_APPFONT ( 99 , 8 ) ; - /* ### ACHTUNG: Neuer Text in Resource? relative Gren : relative Gren */ Text [ en-US ] = "Relative sizes" ; }; OKButton 1 @@ -433,7 +427,6 @@ ModalDialog RID_DISTANCEDIALOG SVLook = TRUE ; HelpID = SID_DISTANCE ; Size = MAP_APPFONT ( 240 , 90 ) ; - /* ### ACHTUNG: Neuer Text in Resource? Abstnde : Abstnde */ Text [ en-US ] = "Spacing" ; FixedText 1 { @@ -564,7 +557,6 @@ ModalDialog RID_DISTANCEDIALOG { String 1 { - /* ### ACHTUNG: Neuer Text in Resource? Abstnde : Abstnde */ Text [ en-US ] = "Spacing" ; }; String 2 @@ -639,12 +631,10 @@ ModalDialog RID_DISTANCEDIALOG { String 1 { - /* ### ACHTUNG: Neuer Text in Resource? Brche : Brche */ Text [ en-US ] = "Fractions" ; }; String 2 { - /* ### ACHTUNG: Neuer Text in Resource? ~Zhlerhhe: : ~Zhlerhhe: */ Text [ en-US ] = "~Numerator"; }; Bitmap 20 @@ -676,7 +666,6 @@ ModalDialog RID_DISTANCEDIALOG }; String 2 { - /* ### ACHTUNG: Neuer Text in Resource? ~berlnge: : ~berlnge: */ Text [ en-US ] = "~Excess length"; }; Bitmap 20 @@ -689,7 +678,6 @@ ModalDialog RID_DISTANCEDIALOG }; String 3 { - /* ### ACHTUNG: Neuer Text in Resource? ~Strichstrke: : ~Strichstrke: */ Text [ en-US ] = "~Weight"; }; Bitmap 30 @@ -709,7 +697,6 @@ ModalDialog RID_DISTANCEDIALOG }; String 2 { - /* ### ACHTUNG: Neuer Text in Resource? Grenz~hhe: : Grenz~hhe: */ Text [ en-US ] = "~Upper limit"; }; Bitmap 20 @@ -815,7 +802,6 @@ ModalDialog RID_DISTANCEDIALOG }; String 2 { - /* ### ACHTUNG: Neuer Text in Resource? ~Primrhhe: : ~Primrhhe: */ Text [ en-US ] = "~Primary height"; }; Bitmap 20 @@ -847,7 +833,6 @@ ModalDialog RID_DISTANCEDIALOG }; String 2 { - /* ### ACHTUNG: Neuer Text in Resource? ~bergre: : ~bergre: */ Text [ en-US ] = "~Excess size"; }; Bitmap 20 @@ -1127,7 +1112,6 @@ ModalDialog RID_SYMBOLDIALOG Pos = MAP_APPFONT ( 177 , 6 ) ; Size = MAP_APPFONT ( 56 , 14 ) ; DefButton = TRUE ; - /* ### ACHTUNG: Neuer Text in Resource? ~bernehmen : ~bernehmen */ Text [ en-US ] = "~Insert" ; }; PushButton 3 @@ -1365,14 +1349,13 @@ ModalDialog RID_SYMDEFINEDIALOG WarningBox RID_NOMATHTYPEFACEWARNING { - Message [ en-US ] = "The \"StarMath\" font has not been installed.\nWithout this font %PRODUCTNAME Math cannot function correctly.\nPlease install this font and restart %PRODUCTNAME Math." ; + Message [ en-US ] = "The 'StarMath' font has not been installed.\nWithout this font %PRODUCTNAME Math cannot function correctly.\nPlease install this font and restart %PRODUCTNAME Math." ; }; QueryBox RID_DEFAULTSAVEQUERY { Buttons = WB_YES_NO ; DefButton = WB_DEF_YES ; - /* ### ACHTUNG: Neuer Text in Resource? Sollen die nderungen als Standard gespeichert werden ?\n\nDiese nderungen wirken sich auf alle neuen Formeln aus. : Sollen die nderungen als Standard gespeichert werden ?\n\nDiese nderungen wirken sich auf alle neuen Formeln aus. */ Message [ en-US ] = "Should the changes be saved as defaults?\n\nThese changes will apply for all new formulas." ; }; @@ -1438,7 +1421,6 @@ Menu RID_VIEWMENU { Identifier = SID_ZOOMIN ; HelpID = SID_ZOOMIN ; - /* ### ACHTUNG: Neuer Text in Resource? Vergrern : Vergrern */ Text [ en-US ] = "~Zoom In" ; }; MenuItem @@ -1759,7 +1741,7 @@ FloatingWindow RID_TOOLBOXWINDOW { Identifier = RID_XSIMEQY ; HelpId = HID_SMA_XSIMEQY ; - /* ### ACHTUNG: Neuer Text in Resource? ist hnlich oder gleich : ist hnlich oder glech */ + /* ### ACHTUNG: Neuer Text in Resource? ist �hnlich oder gleich : ist �hnlich oder glech */ Text [ en-US ] = "Is Similar Or Equal" ; }; ToolBoxItem @@ -1782,7 +1764,6 @@ FloatingWindow RID_TOOLBOXWINDOW { Identifier = RID_XLESLANTY ; HelpId = HID_SMA_XLESLANTY ; - /* ### ACHTUNG: Neuer Text in Resource? ist kleiner gleich (schrg) : ist keiner gleich */ Text [ en-US ] = "Is Less Than Or Equal To" ; }; ToolBoxItem @@ -2051,7 +2032,6 @@ FloatingWindow RID_TOOLBOXWINDOW { Identifier = RID_EX ; HelpId = HID_SMA_EX ; - /* ### ACHTUNG: Neuer Text in Resource? Exponentialfunktion : natrliche Exponentialfunktion */ Text [ en-US ] = "Exponential Function" ; }; ToolBoxItem @@ -2734,7 +2714,6 @@ FloatingWindow RID_TOOLBOXWINDOW { Identifier = RID_ALIGNCX ; HelpId = HID_SMA_ALIGNCX ; - /* ### ACHTUNG: Neuer Text in Resource? zentriert ausrichten : zentriert (horizontal) ausrichten */ Text [ en-US ] = "Align Center" ; }; ToolBoxItem @@ -3456,13 +3435,11 @@ String RID_ERR_FUNCEXPECTED String RID_ERR_UNOPEREXPECTED { - /* ### ACHTUNG: Neuer Text in Resource? Unrer Operator erwartet : Unrer Operator erwartet */ Text [ en-US ] = "Unary operator expected" ; }; String RID_ERR_BINOPEREXPECTED { - /* ### ACHTUNG: Neuer Text in Resource? Binrer Operator erwartet : Binrer Operator erwartet */ Text [ en-US ] = "Binary operator expected" ; }; @@ -3526,9 +3503,7 @@ ToolBox RID_MATH_TOOLBOX { Identifier = SID_ZOOMIN ; HelpID = SID_ZOOMIN ; - /* ### ACHTUNG: Neuer Text in Resource? Grer : Grer */ Text [ en-US ] = "Zoom In" ; - /* ### ACHTUNG: Neuer Text in Resource? Stellt den Ausschnitt vergrert dar : Stellt den Ausschnitt vergrert dar */ }; ToolBoxItem { @@ -3541,7 +3516,6 @@ ToolBox RID_MATH_TOOLBOX Identifier = SID_VIEW100 ; HelpID = SID_VIEW100 ; Text [ en-US ] = "Zoom 100%" ; - /* ### ACHTUNG: Neuer Text in Resource? Stellt den Ausschnitt in tatschlicher Gre dar : Stellt den Ausschnitt in tatschlicher Gre dar */ }; ToolBoxItem { @@ -3570,7 +3544,6 @@ ToolBox RID_MATH_TOOLBOX Identifier = SID_SYMBOLS_CATALOGUE ; HelpID = SID_SYMBOLS_CATALOGUE ; Text [ en-US ] = "Symbols" ; - /* ### ACHTUNG: Neuer Text in Resource? Symbole einfgen und bearbeiten : Symbole einfgen und bearbeiten */ }; }; }; @@ -3580,189 +3553,28 @@ String RID_MATH_TOOLBOX Text [ en-US ] = "Main Toolbar" ; }; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +StringArray RID_PRINTUIOPTIONS +{ + ItemList [en-US] = + { + < "%PRODUCTNAME %s"; >; + < "Contents"; >; + < "~Title row"; >; + < "Specifies whether you want the name of the document to be included in the printout"; >; + < "~Formula text"; >; + < "Specifies whether to include the contents of the 'Commands' window at the bottom of the printout."; >; + < "B~orders"; >; + < "Applies a thin border to the formula area in the printout."; >; + < "Size"; >; + < "O~riginal size"; >; + < "Prints the formula without adjusting the current font size."; >; + < "Fit to ~page"; >; + < "Adjusts the formula to the page format used in the printout."; >; + < "~Scaling"; >; + < "Reduces or enlarges the size of the printed formula by a specified enlargement factor."; >; + < "Miscellaneous options"; >; + < "Ig~nore ~~ and ` at the end of the line"; >; + < "Specfies that these space wildcards will be removed if they are at the end of a line."; >; + }; +}; diff --git a/starmath/source/symbol.cxx b/starmath/source/symbol.cxx index aba0e754b85e..7d2799b71647 100644 --- a/starmath/source/symbol.cxx +++ b/starmath/source/symbol.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: symbol.cxx,v $ - * $Revision: 1.31 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/starmath/source/symbol.src b/starmath/source/symbol.src index 10960643b14d..c4cab66a8212 100644 --- a/starmath/source/symbol.src +++ b/starmath/source/symbol.src @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: symbol.src,v $ - * $Revision: 1.53 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/starmath/source/toolbox.cxx b/starmath/source/toolbox.cxx index 0c108967e0c1..2de6c97ed5ab 100644 --- a/starmath/source/toolbox.cxx +++ b/starmath/source/toolbox.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: toolbox.cxx,v $ - * $Revision: 1.23 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -33,9 +30,9 @@ #include <rtl/logfile.hxx> -#include <svtools/eitem.hxx> +#include <svl/eitem.hxx> #include <sfx2/app.hxx> -#include <svtools/intitem.hxx> +#include <svl/intitem.hxx> #include <svtools/imgdef.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/imgmgr.hxx> diff --git a/starmath/source/toolbox.hrc b/starmath/source/toolbox.hrc index da60b243d646..687521d76a32 100644 --- a/starmath/source/toolbox.hrc +++ b/starmath/source/toolbox.hrc @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: toolbox.hrc,v $ - * $Revision: 1.5 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/starmath/source/typemap.cxx b/starmath/source/typemap.cxx index d0e796533e3f..e98e0b5d85a4 100644 --- a/starmath/source/typemap.cxx +++ b/starmath/source/typemap.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: typemap.cxx,v $ - * $Revision: 1.5 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -141,10 +138,10 @@ #define SvxCellVerJustifyEnumItem SfxVoidItem #define SvxCellOrientationEnumItem SfxVoidItem #include <sfx2/msg.hxx> -#include <svtools/stritem.hxx> -#include <svtools/eitem.hxx> +#include <svl/stritem.hxx> +#include <svl/eitem.hxx> #include <svx/zoomitem.hxx> -#include <svtools/slstitm.hxx> +#include <svl/slstitm.hxx> #define SFX_TYPEMAP #include "smslots.hxx" diff --git a/starmath/source/types.cxx b/starmath/source/types.cxx index 6a4fe919ae95..a861db5a0c79 100644 --- a/starmath/source/types.cxx +++ b/starmath/source/types.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: types.cxx,v $ - * $Revision: 1.6 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -35,227 +32,21 @@ #include <types.hxx> -//!! no official unicode code point for these in non-private-area -//!! (even MathMl uses the code points listed on the right which are -//!! from the private-use-area as well) -// MS_UNDERBRACE = (xub_Unicode) 0xE081, 0xF613 ? -// MS_OVERBRACE = (xub_Unicode) 0xE082, 0xF612 ? - -struct MathConversionEntry -{ - sal_Unicode cMath; // code point of the character from the - // StarSymbol/OpenSymbol private-use-area - sal_Unicode cUnicode; // 'official' Unicode code point the above - // character should be matched to and vice versa. - // See http://www.w3.org/TR/2000/WD-MathML2-20000211/bycodes.html - // for most of them. -// const sal_Unicode *pFontName; - sal_Unicode cMathType; // 0 if the same value of cUnicode is to be used -}; - -static MathConversionEntry aMathConvTbl[] = -{ -// MS_UNDERBRACE, 0xF613, // only Math-ML code-point available ! -// MS_OVERBRACE, 0xF612, // only Math-ML code-point available ! - { MS_PLUS, 0x002B, 0 }, - { MS_LT, 0x003C, 0 }, - { MS_GT, 0x003E, 0 }, - { MS_LESLANT, 0x2264, 0 }, - { MS_GESLANT, 0x2265, 0 }, - { MS_DOTSLOW, 0x2026, 0 }, - { MS_RIGHTARROW, 0x2192, 0 }, - { MS_SQRT, 0x221A, 0 }, - { MS_HAT, 0x02C6, 0 }, - { MS_CHECK, 0x02C7, 0 }, - { MS_BREVE, 0x02D8, 0 }, - { MS_ACUTE, 0x00B4, 0 }, - { MS_GRAVE, 0x0060, 0 }, - { MS_TILDE, 0x02DC, 0 }, - { MS_BAR, 0x02C9, 0 }, - { MS_VEC, 0x2192, 0 }, - { MS_DDDOT, 0x22EF, 0 }, - { MS_LPARENT, 0x0028, 0 }, - { MS_RPARENT, 0x0029, 0 }, - { MS_PLACE, 0x25A1, 0 }, - { MS_LEFTARROW, 0x2190, 0 }, - { MS_UPARROW, 0x2191, 0 }, - { MS_DOWNARROW, 0x2193, 0 }, - { MS_PLACE, 0x2751, 0 }, - - // predefined-user-defined symbols - // (code-points on the left as defined in 'officecfg' for SO8, - // non-private-use-area characters uncommented): - -// 0x0041, 0x0391, 0, // %ALPHA -// 0x0042, 0x0392, 0, // %BETA - { 0xE0AC, 0x0393, 0 }, // %GAMMA - { 0xE0AD, 0x0394, 0 }, // %DELTA -// 0x0045, 0x0395, 0, // %EPSILON -// 0x005A, 0x0396, 0, // %ZETA -// 0x0048, 0x0397, 0, // %ETA - { 0xE0AE, 0x0398, 0 }, // %THETA -// 0x0049, 0x0399, 0, // %IOTA -// 0x004B, 0x039A, 0, // %KAPPA - { 0xE0AF, 0x039B, 0 }, // %LAMBDA -// 0x004D, 0x039C, 0, // %MU -// 0x004E, 0x039D, 0, // %NU - { 0xE0B0, 0x039E, 0 }, // %XI -// 0x004F, 0x039F, 0, // %OMICRON - { 0xE0B1, 0x03A0, 0 }, // %PI -// 0x0050, 0x03A1, 0, // %RHO - { 0xE0B2, 0x03A3, 0 }, // %SIGMA -// 0x0054, 0x03A4, 0, // %TAU - { 0xE0B3, 0x03A5, 0 }, // %UPSILON - { 0xE0B4, 0x03A6, 0 }, // %PHI -// 0x0058, 0x03A7, 0, // %CHI - { 0xE0B5, 0x03A8, 0 }, // %PSI - { 0xE0B6, 0x03A9, 0 }, // %OMEGA - - { 0xE0B7, 0x03B1, 0 }, // %alpha - { 0xE0B8, 0x03B2, 0 }, // %beta - { 0xE0B9, 0x03B3, 0 }, // %gamma - { 0xE0BA, 0x03B4, 0 }, // %delta - { 0xE0BB, 0x03B5, 0 }, // %epsilon - { 0xE0BC, 0x03B6, 0 }, // %zeta - { 0xE0BD, 0x03B7, 0 }, // %eta - { 0xE0BE, 0x03B8, 0 }, // %theta - { 0xE0BF, 0x03B9, 0 }, // %iota - { 0xE0C0, 0x03BA, 0 }, // %kappa - { 0xE0C1, 0x03BB, 0 }, // %lambda - { 0xE0C2, 0x03BC, 0 }, // %mu - { 0xE0C3, 0x03BD, 0 }, // %nu - { 0xE0C4, 0x03BE, 0 }, // %xi - { 0xE0C5, 0x03BF, 0 }, // %omicron - { 0xE0C6, 0x03C0, 0 }, // %pi - { 0xE0C7, 0x03C1, 0 }, // %rho - { 0xE0C8, 0x03C3, 0 }, // %sigma - { 0xE0C9, 0x03C4, 0 }, // %tau - { 0xE0CA, 0x03C5, 0 }, // %upsilon - { 0xE0CB, 0x03C6, 0 }, // %phi - { 0xE0CC, 0x03C7, 0 }, // %chi - { 0xE0CD, 0x03C8, 0 }, // %psi - { 0xE0CE, 0x03C9, 0 }, // %omega - - { 0xE0CF, 0x025B, 0,/*x03B5*/}, // %varepsilon - { 0xE0D0, 0x03D1, 0 }, // %vartheta - { 0xE0D4, 0x03D5, 0 }, // %varphi - { 0xE0D1, 0x03D6, 0 }, // %varpi -// 0x03F1, 0x03F1, 0/*x03C1*/, // %varrho - { 0xE0D3, 0x03C2, 0 }, // %varsigma - -// 0x2227, 0x2227, 0, // %and -// 0x2228, 0x2228, 0, // %or -// 0x2208, 0x2208, 0, // %element -// 0x2209, 0x2209, 0, // %noelement -// 0x226B, 0x226B, 0, // %strictlygreaterthan -// 0x226A, 0x226A, 0, // %strictlylessthan -// 0x2261, 0x2261, 0, // %identical -// 0x221E, 0x221E, 0, // %infinite -// 0x2260, 0x2260, 0, // %notequal - { 0xE080, 0x2030, 0 }, // %perthousand -// 0x2222, 0x2222, 0, // %angle - { 0xE08C, 0x2192, 0 } // %tendto -}; - - -static int nMathToUnicodeLen = sizeof(aMathConvTbl) / sizeof(aMathConvTbl[0]); - sal_Unicode ConvertMathPrivateUseAreaToUnicode( sal_Unicode cChar ) { - sal_Unicode cRes = 0; + sal_Unicode cRes = cChar; if (IsInPrivateUseArea( cChar )) { - for (int i = 0; i < nMathToUnicodeLen && cRes == 0; ++i) - { - if (aMathConvTbl[i].cMath == cChar) - cRes = aMathConvTbl[i].cUnicode; - } - } - return cRes; -} - -#ifdef TL_NOT_YET_USED -sal_Unicode ConvertUnicodeToMathPrivateUseArea( sal_Unicode cChar ) -{ - sal_Unicode cRes = 0; - for (int i = 0; i < nMathToUnicodeLen && cRes == 0; ++i) - { - if (aMathConvTbl[i].cUnicode == cChar) - cRes = aMathConvTbl[i].cMath; + DBG_ASSERT( 0, "Error: private use area characters should no longer be in use!" ); + cRes = (sal_Unicode) '&'; // just some character that should easily be notice as odd in the context } return cRes; } -sal_Unicode ConvertMathToMathType( sal_Unicode cChar ) -{ - sal_Unicode cRes = 0; - for (int i = 0; i < nMathToUnicodeLen && cRes == 0; ++i) - { - const MathConversionEntry &rEntry = aMathConvTbl[i]; - if (rEntry.cMath == cChar) - { - cRes = rEntry.cMathType; - if (cRes == 0) - cRes = rEntry.cUnicode; - } - } - return cRes; -} - -sal_Unicode ConvertMathTypeToMath( sal_Unicode cChar ) -{ - sal_Unicode cRes = 0; - for (int i = 0; i < nMathToUnicodeLen && cRes == 0; ++i) - { - const MathConversionEntry &rEntry = aMathConvTbl[i]; - sal_Unicode cTmp = rEntry.cMathType; - if (cTmp == 0) - cTmp = rEntry.cUnicode; - if (cTmp == cChar) - cRes = rEntry.cMath; - } - return cRes; -} -#endif //TL_NOT_YET_USED - sal_Unicode ConvertMathToMathML( sal_Unicode cChar ) { - sal_Unicode cRes = 0; - if (cChar == MS_OVERBRACE) - cRes = 0xF612; // Math-ML code-point (there is no official unicode-point) - else if (cChar == MS_UNDERBRACE) - cRes = 0xF613; // Math-ML code-point (there is no official unicode-point) - else - cRes = ConvertMathPrivateUseAreaToUnicode( cChar ); - return cRes; -} - -#ifdef TL_NOT_YET_USED -sal_Unicode ConvertMathMLToMath( sal_Unicode cChar ) -{ - sal_Unicode cRes = 0; - if (cChar == 0xF612) - cRes = MS_OVERBRACE; // Math-ML code-point (there is no official unicode-point) - else if (cChar == 0xF613) - cRes = MS_UNDERBRACE; // Math-ML code-point (there is no official unicode-point) - else - cRes = ConvertUnicodeToMathPrivateUseArea( cChar ); + sal_Unicode cRes = ConvertMathPrivateUseAreaToUnicode( cChar ); return cRes; } - -sal_Unicode GetTokenChar( sal_Unicode cChar, sal_Bool bConvertForExport ) -{ - sal_Unicode cRes = cChar; - if (bConvertForExport) - { - sal_Unicode cTmp = ConvertMathPrivateUseAreaToUnicode( cChar ); - if (cTmp != 0) - cRes = cTmp; - } - return cRes; -} -#endif //TL_NOT_YET_USED - - diff --git a/starmath/source/unodoc.cxx b/starmath/source/unodoc.cxx index 3f213c0ee256..1a2ff371f212 100644 --- a/starmath/source/unodoc.cxx +++ b/starmath/source/unodoc.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: unodoc.cxx,v $ - * $Revision: 1.8 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx index ed6e5b6bd23f..f4acc1af6b89 100644 --- a/starmath/source/unomodel.cxx +++ b/starmath/source/unomodel.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: unomodel.cxx,v $ - * $Revision: 1.49 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -37,11 +34,12 @@ #include <sfx2/printer.hxx> #include <vcl/svapp.hxx> #include <svtools/ctrltool.hxx> -#include <svtools/itemprop.hxx> +#include <svl/itemprop.hxx> #include <unotools/localedatawrapper.hxx> #include <unotools/processfactory.hxx> -#include <svx/paperinf.hxx> +#include <editeng/paperinf.hxx> #include <vcl/settings.hxx> +#include <vcl/print.hxx> #include <toolkit/awt/vclxdevice.hxx> #include <com/sun/star/beans/PropertyState.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> @@ -51,15 +49,14 @@ #include <xmloff/xmluconv.hxx> #include <rtl/ustrbuf.hxx> #include <comphelper/propertysetinfo.hxx> +#include <unotools/moduleoptions.hxx> + #include <unomodel.hxx> #include <document.hxx> #include <view.hxx> #include <symbol.hxx> -#ifndef STARMATH_HRC #include <starmath.hrc> -#endif #include <config.hxx> - #include <smdll.hxx> using namespace ::vos; @@ -75,11 +72,102 @@ using namespace ::com::sun::star::formula; using namespace ::com::sun::star::view; using namespace ::com::sun::star::script; + #define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L)) #define MM100_TO_TWIP(MM100) ((MM100) >= 0 ? (((MM100)*72L+63L)/127L) : (((MM100)*72L-63L)/127L)) +//////////////////////////////////////////////////////////// -//////////////////////////////////////// +SmPrintUIOptions::SmPrintUIOptions() +{ + ResStringArray aLocalizedStrings( SmResId( RID_PRINTUIOPTIONS ) ); + DBG_ASSERT( aLocalizedStrings.Count() >= 18, "resource incomplete" ); + if( aLocalizedStrings.Count() < 18 ) // bad resource ? + return; + + SmModule *pp = SM_MOD1(); + SmConfig *pConfig = pp->GetConfig(); + DBG_ASSERT( pConfig, "SmConfig not found" ); + if (!pConfig) + return; + + // create sequence of print UI options + // (Actually IsIgnoreSpacesRight is a parser option. Without it we need only 8 properties here.) + m_aUIProperties.realloc( 9 ); + + // create Section for formula (results in an extra tab page in dialog) + SvtModuleOptions aOpt; + String aAppGroupname( aLocalizedStrings.GetString( 0 ) ); + aAppGroupname.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s" ) ), + aOpt.GetModuleName( SvtModuleOptions::E_SMATH ) ); + m_aUIProperties[0].Value = getGroupControlOpt( aAppGroupname, rtl::OUString() ); + + // create subgroup for print options + m_aUIProperties[1].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 1 ), rtl::OUString() ); + + // create a bool option for title row (matches to SID_PRINTTITLE) + m_aUIProperties[2].Value = getBoolControlOpt( aLocalizedStrings.GetString( 2 ), + aLocalizedStrings.GetString( 3 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( PRTUIOPT_TITLE_ROW ) ), + pConfig->IsPrintTitle() ); + // create a bool option for formula text (matches to SID_PRINTTEXT) + m_aUIProperties[3].Value = getBoolControlOpt( aLocalizedStrings.GetString( 4 ), + aLocalizedStrings.GetString( 5 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( PRTUIOPT_FORMULA_TEXT ) ), + pConfig->IsPrintFormulaText() ); + // create a bool option for border (matches to SID_PRINTFRAME) + m_aUIProperties[4].Value = getBoolControlOpt( aLocalizedStrings.GetString( 6 ), + aLocalizedStrings.GetString( 7 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( PRTUIOPT_BORDER ) ), + pConfig->IsPrintFrame() ); + + // create subgroup for print format + m_aUIProperties[5].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 8 ), rtl::OUString() ); + + // create a radio button group for print format (matches to SID_PRINTSIZE) + Sequence< rtl::OUString > aChoices( 3 ); + aChoices[0] = aLocalizedStrings.GetString( 9 ); + aChoices[1] = aLocalizedStrings.GetString( 11 ); + aChoices[2] = aLocalizedStrings.GetString( 13 ); + Sequence< rtl::OUString > aHelpTexts( 3 ); + aHelpTexts[0] = aLocalizedStrings.GetString( 10 ); + aHelpTexts[1] = aLocalizedStrings.GetString( 12 ); + aHelpTexts[2] = aLocalizedStrings.GetString( 14 ); + OUString aPrintFormatProp( RTL_CONSTASCII_USTRINGPARAM( PRTUIOPT_PRINT_FORMAT ) ); + m_aUIProperties[6].Value = getChoiceControlOpt( rtl::OUString(), + aHelpTexts, + aPrintFormatProp, + aChoices, static_cast< sal_Int32 >(pConfig->GetPrintSize()) + ); + + // create a numeric box for scale dependent on PrintFormat = "Scaling" (matches to SID_PRINTZOOM) + vcl::PrinterOptionsHelper::UIControlOptions aRangeOpt( aPrintFormatProp, 2, sal_True ); + m_aUIProperties[ 7 ].Value = getRangeControlOpt( rtl::OUString(), + aLocalizedStrings.GetString( 14 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( PRTUIOPT_PRINT_SCALE ) ), + pConfig->GetPrintZoomFactor(), // initial value + 10, // min value + 1000, // max value + aRangeOpt ); + + Sequence< PropertyValue > aHintNoLayoutPage( 1 ); + aHintNoLayoutPage[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HintNoLayoutPage" ) ); + aHintNoLayoutPage[0].Value = makeAny( sal_True ); + m_aUIProperties[8].Value <<= aHintNoLayoutPage; + +// IsIgnoreSpacesRight is a parser option! Thus we don't add it to the printer UI. +// +// // create subgroup for misc options +// m_aUIProperties[8].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 9 ) ); +// +// // create a bool option for ignore spacing (matches to SID_NO_RIGHT_SPACES) +// m_aUIProperties[9].Value = getBoolControlOpt( aLocalizedStrings.GetString( 10 ), +// rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( PRTUIOPT_NO_RIGHT_SPACE ) ), +// pConfig->IsIgnoreSpacesRight() ); +} + + +//////////////////////////////////////////////////////////// // // class SmModel // @@ -229,11 +317,14 @@ PropertySetInfo * lcl_createModelPropertyInfo () SmModel::SmModel( SfxObjectShell *pObjSh ) : SfxBaseModel(pObjSh) , PropertySetHelper ( lcl_createModelPropertyInfo () ) +, m_pPrintUIOptions( NULL ) + { } //----------------------------------------------------------------------- SmModel::~SmModel() throw () { + delete m_pPrintUIOptions; } /*-- 28.03.00 14:18:17--------------------------------------------------- @@ -862,10 +953,33 @@ sal_Int32 SAL_CALL SmModel::getRendererCount( return 1; } + +static Size lcl_GuessPaperSize() +{ + Size aRes; + Reference< XMultiServiceFactory > xMgr( getProcessServiceFactory() ); + LocaleDataWrapper aLocWrp( xMgr, AllSettings().GetLocale() ); + if( MEASURE_METRIC == aLocWrp.getMeasurementSystemEnum() ) + { + // in 100th mm + PaperInfo aInfo( PAPER_A4 ); + aRes.Width() = aInfo.getWidth(); + aRes.Height() = aInfo.getHeight(); + } + else + { + // in 100th mm + PaperInfo aInfo( PAPER_LETTER ); + aRes.Width() = aInfo.getWidth(); + aRes.Height() = aInfo.getHeight(); + } + return aRes; +} + uno::Sequence< beans::PropertyValue > SAL_CALL SmModel::getRenderer( sal_Int32 nRenderer, const uno::Any& /*rSelection*/, - const uno::Sequence< beans::PropertyValue >& /*xOptions*/ ) + const uno::Sequence< beans::PropertyValue >& /*rxOptions*/ ) throw (IllegalArgumentException, RuntimeException) { ::vos::OGuard aGuard(Application::GetSolarMutex()); @@ -885,7 +999,7 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SmModel::getRenderer( // if paper size is 0 (usually if no 'real' printer is found), // guess the paper size if (aPrtPaperSize.Height() == 0 || aPrtPaperSize.Width() == 0) - aPrtPaperSize = SvxPaperInfo::GetDefaultPaperSize(MAP_100TH_MM); + aPrtPaperSize = lcl_GuessPaperSize(); awt::Size aPageSize( aPrtPaperSize.Width(), aPrtPaperSize.Height() ); uno::Sequence< beans::PropertyValue > aRenderer(1); @@ -893,6 +1007,10 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SmModel::getRenderer( rValue.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ); rValue.Value <<= aPageSize; + if (!m_pPrintUIOptions) + m_pPrintUIOptions = new SmPrintUIOptions(); + m_pPrintUIOptions->appendPrintUIOptions( aRenderer ); + return aRenderer; } @@ -954,7 +1072,7 @@ void SAL_CALL SmModel::render( // no real printer ?? if (aPrtPaperSize.Height() == 0 || aPrtPaperSize.Width() == 0) { - aPrtPaperSize = SvxPaperInfo::GetDefaultPaperSize(MAP_100TH_MM); + aPrtPaperSize = lcl_GuessPaperSize(); // factors from Windows DIN A4 aOutputSize = Size( (long)(aPrtPaperSize.Width() * 0.941), (long)(aPrtPaperSize.Height() * 0.961)); @@ -979,8 +1097,18 @@ void SAL_CALL SmModel::render( OutputRect.Right() -= 1500 - (aPrtPaperSize.Width() - (aPrtPageOffset.X() + OutputRect.Right())); - pView->Impl_Print( *pOut, PRINT_SIZE_NORMAL, - Rectangle( OutputRect ), Point() ); + if (!m_pPrintUIOptions) + m_pPrintUIOptions = new SmPrintUIOptions(); + m_pPrintUIOptions->processProperties( rxOptions ); + + pView->Impl_Print( *pOut, *m_pPrintUIOptions, Rectangle( OutputRect ), Point() ); + + // release SmPrintUIOptions when everything is done. + // That way, when SmPrintUIOptions is needed again it will read the latest configuration settings in its c-tor. + if (m_pPrintUIOptions->getBoolValue( "IsLastPage", sal_False )) + { + delete m_pPrintUIOptions; m_pPrintUIOptions = 0; + } } } } diff --git a/starmath/source/utility.cxx b/starmath/source/utility.cxx index e6fed5946088..0000bf5cf766 100644 --- a/starmath/source/utility.cxx +++ b/starmath/source/utility.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: utility.cxx,v $ - * $Revision: 1.20 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx index 5492553e46fe..c114f8f3367a 100644 --- a/starmath/source/view.cxx +++ b/starmath/source/view.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: view.cxx,v $ - * $Revision: 1.53 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -51,17 +48,17 @@ #include <sfx2/objface.hxx> #include <sfx2/printer.hxx> #include <sfx2/request.hxx> -#include <svtools/eitem.hxx> -#include <svtools/intitem.hxx> -#include <svtools/itemset.hxx> -#include <svtools/poolitem.hxx> -#include <svtools/ptitem.hxx> -#include <svtools/stritem.hxx> +#include <svl/eitem.hxx> +#include <svl/intitem.hxx> +#include <svl/itemset.hxx> +#include <svl/poolitem.hxx> +#include <svl/ptitem.hxx> +#include <svl/stritem.hxx> #include <svtools/transfer.hxx> -#include <svtools/undo.hxx> -#include <svtools/whiter.hxx> +#include <svl/undo.hxx> +#include <svl/whiter.hxx> #include <svx/dialogs.hrc> -#include <svx/editeng.hxx> +#include <editeng/editeng.hxx> #include <svx/svxdlg.hxx> #include <svx/zoomitem.hxx> #include <vcl/decoview.hxx> @@ -69,6 +66,7 @@ #include <vcl/msgbox.hxx> #include <vcl/wrkwin.hxx> +#include "unomodel.hxx" #include "view.hxx" #include "config.hxx" #include "dialog.hxx" @@ -89,8 +87,6 @@ #define SmViewShell #include "smslots.hxx" - - using namespace com::sun::star; using namespace com::sun::star::accessibility; using namespace com::sun::star::uno; @@ -1010,18 +1006,25 @@ void SmViewShell::DrawText(OutputDevice& rDevice, const Point& rPosition, const } void SmViewShell::Impl_Print( - OutputDevice &rOutDev, const SmPrintSize ePrintSize, + OutputDevice &rOutDev, + const SmPrintUIOptions &rPrintUIOptions, Rectangle aOutRect, Point aZeroPoint ) { RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::Impl_Print" ); - SmModule *pp = SM_MOD1(); + const bool bIsPrintTitle = rPrintUIOptions.getBoolValue( PRTUIOPT_TITLE_ROW, sal_True ); + const bool bIsPrintFrame = rPrintUIOptions.getBoolValue( PRTUIOPT_BORDER, sal_True ); + const bool bIsPrintFormulaText = rPrintUIOptions.getBoolValue( PRTUIOPT_FORMULA_TEXT, sal_True ); + SmPrintSize ePrintSize( static_cast< SmPrintSize >( rPrintUIOptions.getIntValue( PRTUIOPT_PRINT_FORMAT, PRINT_SIZE_NORMAL ) )); + const USHORT nZoomFactor = static_cast< USHORT >(rPrintUIOptions.getIntValue( PRTUIOPT_PRINT_SCALE, 100 )); +// IsIgnoreSpacesRight is a parser option! Thus it does not get evaluated here anymore (too late). +// const bool bNoRightSpaces = rPrintUIOptions.getBoolValue( PRTUIOPT_NO_RIGHT_SPACE, sal_True ); rOutDev.Push(); rOutDev.SetLineColor( Color(COL_BLACK) ); // output text on top - if (pp->GetConfig()->IsPrintTitle()) + if (bIsPrintTitle) { Size aSize600 (0, 600); Size aSize650 (0, 650); @@ -1041,7 +1044,7 @@ void SmViewShell::Impl_Print( Size aDescSize (GetTextSize(rOutDev, GetDoc()->GetComment(), aOutRect.GetWidth() - 200)); - if (pp->GetConfig()->IsPrintFrame()) + if (bIsPrintFrame) rOutDev.DrawRect(Rectangle(aOutRect.TopLeft(), Size(aOutRect.GetWidth(), 100 + aTitleSize.Height() + 200 + aDescSize.Height() + 100))); aOutRect.Top() += 200; @@ -1068,11 +1071,9 @@ void SmViewShell::Impl_Print( } // output text on bottom - if (pp->GetConfig()->IsPrintFormulaText()) + if (bIsPrintFormulaText) { -// Font aFont(FAMILY_DONTKNOW, Size(0, 600)); - Font aFont; - + Font aFont(FAMILY_DONTKNOW, Size(0, 600)); aFont.SetAlign(ALIGN_TOP); aFont.SetColor( Color(COL_BLACK) ); @@ -1083,7 +1084,7 @@ void SmViewShell::Impl_Print( aOutRect.Bottom() -= aSize.Height() + 600; - if (pp->GetConfig()->IsPrintFrame()) + if (bIsPrintFrame) rOutDev.DrawRect(Rectangle(aOutRect.BottomLeft(), Size(aOutRect.GetWidth(), 200 + aSize.Height() + 200))); @@ -1094,7 +1095,7 @@ void SmViewShell::Impl_Print( aOutRect.Bottom() -= 200; } - if (pp->GetConfig()->IsPrintFrame()) + if (bIsPrintFrame) rOutDev.DrawRect(aOutRect); aOutRect.Top() += 100; @@ -1105,6 +1106,9 @@ void SmViewShell::Impl_Print( Size aSize (GetDoc()->GetSize()); MapMode OutputMapMode; + // PDF export should always use PRINT_SIZE_NORMAL ... + if (!rPrintUIOptions.getBoolValue( "IsPrinter", sal_False ) ) + ePrintSize = PRINT_SIZE_NORMAL; switch (ePrintSize) { case PRINT_SIZE_NORMAL: @@ -1129,7 +1133,7 @@ void SmViewShell::Impl_Print( case PRINT_SIZE_ZOOMED: { - Fraction aFraction (pp->GetConfig()->GetPrintZoomFactor(), 100); + Fraction aFraction( nZoomFactor, 100 ); OutputMapMode = MapMode(MAP_100TH_MM, aZeroPoint, aFraction, aFraction); break; @@ -1155,44 +1159,10 @@ void SmViewShell::Impl_Print( rOutDev.Pop(); } -USHORT SmViewShell::Print(SfxProgress &rProgress, BOOL bIsAPI, PrintDialog *pPrintDialog) +USHORT SmViewShell::Print(SfxProgress & /*rProgress*/, BOOL /*bIsAPI*/, PrintDialog * /*pPrintDialog*/) { RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::Print" ); - - SmPrinterAccess aPrinterAccess( *GetDoc() ); - Printer *pPrinter = aPrinterAccess.GetPrinter(); - //OutputDevice *pOutDev = pPrinter; - - SfxViewShell::Print (rProgress, bIsAPI, pPrintDialog); - - pPrinter->StartPage(); - - Point aZeroPoint; - Rectangle OutputRect( aZeroPoint, pPrinter->GetOutputSize() ); - - Point aPrtPageOffset( pPrinter->GetPageOffset() ); - Size aPrtPaperSize ( pPrinter->GetPaperSize() ); - - // set minimum top and bottom border - if (aPrtPageOffset.Y() < 2000) - OutputRect.Top() += 2000 - aPrtPageOffset.Y(); - if ((aPrtPaperSize.Height() - (aPrtPageOffset.Y() + OutputRect.Bottom())) < 2000) - OutputRect.Bottom() -= 2000 - (aPrtPaperSize.Height() - - (aPrtPageOffset.Y() + OutputRect.Bottom())); - - // set minimum left and right border - if (aPrtPageOffset.X() < 2500) - OutputRect.Left() += 2500 - aPrtPageOffset.X(); - if ((aPrtPaperSize.Width() - (aPrtPageOffset.X() + OutputRect.Right())) < 1500) - OutputRect.Right() -= 1500 - (aPrtPaperSize.Width() - - (aPrtPageOffset.X() + OutputRect.Right())); - - SmModule *pp = SM_MOD1(); - Impl_Print( *pPrinter, pp->GetConfig()->GetPrintSize(), - OutputRect, aZeroPoint ); - - pPrinter->EndPage(); - + DBG_ASSERT( 0, "SmViewShell::Print: no longer usewd with new UI print dialog. Should be removed!!" ); return 0; } @@ -1653,7 +1623,7 @@ void SmViewShell::Execute(SfxRequest& rReq) SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); if(pFact) { - pDlg = pFact->CreateSvxZoomDialog(&GetViewFrame()->GetWindow(), aSet, RID_SVXDLG_ZOOM); + pDlg = pFact->CreateSvxZoomDialog(&GetViewFrame()->GetWindow(), aSet); DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001 } pDlg->SetLimits( MINZOOM, MAXZOOM ); diff --git a/starmath/util/hidother.src b/starmath/util/hidother.src index d11beb6f62ce..e55a97852b62 100644 --- a/starmath/util/hidother.src +++ b/starmath/util/hidother.src @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: hidother.src,v $ - * $Revision: 1.4 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/starmath/util/makefile.mk b/starmath/util/makefile.mk index 978cb6cff40c..09e738299419 100644 --- a/starmath/util/makefile.mk +++ b/starmath/util/makefile.mk @@ -2,14 +2,10 @@ # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # -# Copyright 2008 by Sun Microsystems, Inc. +# Copyright 2000, 2010 Oracle and/or its affiliates. # # OpenOffice.org - a multi-platform office productivity suite # -# $RCSfile: makefile.mk,v $ -# -# $Revision: 1.20 $ -# # This file is part of OpenOffice.org. # # OpenOffice.org is free software: you can redistribute it and/or modify @@ -57,6 +53,7 @@ SHL1DEF=$(MISC)$/$(SHL1TARGET).def DEF1NAME= $(SHL1TARGET) SHL1STDLIBS= \ + $(EDITENGLIB) \ $(SVXCORELIB) \ $(SVXLIB) \ $(SFX2LIB) \ @@ -65,6 +62,7 @@ SHL1STDLIBS= \ $(TKLIB) \ $(VCLLIB) \ $(SVLLIB) \ + $(I18NPAPERLIB) \ $(SOTLIB) \ $(UNOTOOLSLIB) \ $(TOOLSLIB) \ |