22#include <tqstringlist.h>
26#include <kiconloader.h>
28#include <ksimpleconfig.h>
29#include <kstandarddirs.h>
31#include <KoDocument.h>
33#include "contextstyle.h"
34#include "creationstrategy.h"
35#include "oasiscreationstrategy.h"
36#include "kformulacontainer.h"
37#include "kformuladocument.h"
38#include "sequenceelement.h"
39#include "symboltable.h"
40#include "symbolaction.h"
42KFORMULA_NAMESPACE_BEGIN
44static const int CURRENT_SYNTAX_VERSION = 1;
46static const char * CURRENT_DTD_VERSION =
"1.3";
48int FormulaList::compareItems( TQPtrCollection::Item a, TQPtrCollection::Item b )
50 double ya =
static_cast<Container*
>( a )->getDocumentY();
51 double yb =
static_cast<Container*
>( b )->getDocumentY();
52 if ( fabs( ya-yb ) < 1e-4 ) {
53 double xa =
static_cast<Container*
>( a )->getDocumentX();
54 double xb =
static_cast<Container*
>( b )->getDocumentX();
55 if ( xa < xb )
return -1;
56 if ( xa > xb )
return 1;
59 if ( ya < yb )
return -1;
65 const TQStringList & )
66 : TQObject( parent, name ), m_wrapper( 0 ), m_formula( 0 ), creationStrategy( 0 )
70 formulae.setAutoDelete(
false );
79 int count = formulae.count();
80 for (
int i=count-1; i>=0; --i ) {
81 delete formulae.at( i );
83 delete m_contextStyle;
87bool Document::hasFormula()
89 return ( m_formula != 0 ) && ( m_formula->
activeCursor() != 0 );
103 return TQPtrListIterator<Container>( formulae );
109 return formulae.find( formula );
115 return formulae.at( pos );
121 return formulae.count();
130 TQDomElement root = doc.documentElement();
133 if ( root.tagName() ==
"FORMULA" ) {
135 return formula->
load( root );
138 TQDomNode node = root.firstChild();
139 if ( node.isElement() ) {
140 TQDomElement element = node.toElement();
141 if ( element.tagName() ==
"FORMULASETTINGS" ) {
146 node = node.nextSibling();
149 while ( !node.isNull() ) {
150 if ( node.isElement() ) {
151 TQDomElement element = node.toElement();
152 Container* formula = newFormula( number );
153 if ( !formula->
load( element ) ) {
158 node = node.nextSibling();
160 return formulae.count() > 0;
167 KFormula::Container* formula = newFormula( 0 );
168 return formula->loadMathML( doc,
true );
179 TQDomElement root = doc.documentElement();
181 uint count = formulae.count();
182 for ( uint i=0; i<count; ++i ) {
183 formulae.at( i )->save( root );
191 TQDomElement settings = doc.createElement(
"FORMULASETTINGS" );
199 CURRENT_DTD_VERSION );
208 TQDomDocumentType dt =
209 TQDomImplementation().createDocumentType(
"math",
210 "-//W3C//DTD MathML 2.0//EN",
211 "http://www.w3.org/TR/MathML2/dtd/mathml2.dtd");
212 TQDomDocument doc( dt );
213 doc.insertBefore( doc.createProcessingInstruction(
"xml",
214 "version=\"1.0\" encoding=\"UTF-8\"" ),
215 doc.documentElement() );
227 if ( !creationStrategy || creationStrategy->type() != strategy ) {
228 delete creationStrategy;
229 if ( strategy ==
"Ordinary" )
233 SequenceElement::setCreationStrategy( creationStrategy );
240 (
static_cast<uint
>( pos ) < formulae.count() ) ) {
241 formulae.insert( pos, f );
245 formulae.append( f );
252 if ( m_formula == f ) {
255 formulae.removeRef( f );
270Container* Document::newFormula( uint number )
272 if ( number < formulae.count() ) {
273 return formulae.at( number );
279double Document::getXResolution()
const
283double Document::getYResolution()
const
285 return m_contextStyle->zoomedResolutionY();
295 m_contextStyle->setEdit( edit );
296 return *m_contextStyle;
304void Document::newZoomAndResolution(
bool updateViews,
bool )
312 double zoomX,
double zoomY,
313 bool updateViews,
bool forPrint )
321SymbolType Document::leftBracketChar()
323 return m_wrapper->leftBracketChar();
326SymbolType Document::rightBracketChar()
328 return m_wrapper->rightBracketChar();
340 return m_wrapper->getHistory();
344void Document::recalc()
348 f=formulae.next() ) {
356 m_wrapper->updateConfig();
364 m_contextStyle->
readConfig( wrapper->config(), init );
365 m_contextStyle->
init( init );
371DocumentWrapper::DocumentWrapper( TDEConfig* config,
375 m_leftBracketChar( LeftRoundBracket ),
376 m_rightBracketChar( RightRoundBracket ),
378 m_hasActions( collection != 0 )
380 if ( m_hasActions ) {
381 createActions( collection );
382 enableMatrixActions(
false );
384 setCommandStack( history );
388DocumentWrapper::~DocumentWrapper()
391 if ( m_ownHistory ) {
397 m_config->setGroup(
"General");
398 m_config->writeEntry(
"syntaxHighlighting", m_syntaxHighlightingAction->
isChecked() );
406 m_document->introduceWrapper(
this, init );
407 initSymbolNamesAction();
408 m_config->setGroup(
"General");
411 m_syntaxHighlightingAction->
setChecked( m_config->readBoolEntry(
"syntaxHighlighting",
true ) );
412 if ( !m_syntaxHighlightingAction->
isChecked() )
413 toggleSyntaxHighlighting();
415 else if ( m_config->readBoolEntry(
"syntaxHighlighting",
true ) )
417 m_document->m_contextStyle->setSyntaxHighlighting(
true );
419 m_document->recalc();
426 if ( history == 0 ) {
432 m_ownHistory =
false;
439 TDEGlobal::dirs()->addResourceType(
"toolbar",
440 TDEStandardDirs::kde_default(
"data") +
443 m_addNegThinSpaceAction =
new TDEAction( i18n(
"Add Negative Thin Space" ),
445 this, TQ_SLOT( addNegThinSpace() ),
446 collection,
"formula_addnegthinspace") ;
447 m_addThinSpaceAction =
new TDEAction( i18n(
"Add Thin Space" ),
449 this, TQ_SLOT( addThinSpace() ),
450 collection,
"formula_addthinspace") ;
451 m_addMediumSpaceAction =
new TDEAction( i18n(
"Add Medium Space" ),
453 this, TQ_SLOT( addMediumSpace() ),
454 collection,
"formula_addmediumspace" );
455 m_addThickSpaceAction =
new TDEAction( i18n(
"Add Thick Space" ),
457 this, TQ_SLOT( addThickSpace() ),
458 collection,
"formula_addthickspace" );
459 m_addQuadSpaceAction =
new TDEAction( i18n(
"Add Quad Space" ),
461 this, TQ_SLOT( addQuadSpace() ),
462 collection,
"formula_addquadspace" );
464 m_addIntegralAction =
new TDEAction(i18n(
"Add Integral"),
467 this, TQ_SLOT(addIntegral()),
468 collection,
"formula_addintegral");
469 m_addSumAction =
new TDEAction(i18n(
"Add Sum"),
472 this, TQ_SLOT(addSum()),
473 collection,
"formula_addsum");
474 m_addProductAction =
new TDEAction(i18n(
"Add Product"),
477 this, TQ_SLOT(addProduct()),
478 collection,
"formula_addproduct");
479 m_addRootAction =
new TDEAction(i18n(
"Add Root"),
482 this, TQ_SLOT(addRoot()),
483 collection,
"formula_addroot");
484 m_addFractionAction =
new TDEAction(i18n(
"Add Fraction"),
487 this, TQ_SLOT(addFraction()),
488 collection,
"formula_addfrac");
489 m_addBracketAction =
new TDEAction(i18n(
"Add Bracket"),
492 this, TQ_SLOT(addDefaultBracket()),
493 collection,
"formula_addbra");
494 m_addSBracketAction =
new TDEAction(i18n(
"Add Square Bracket"),
497 this, TQ_SLOT(addSquareBracket()),
498 collection,
"formula_addsqrbra");
499 m_addCBracketAction =
new TDEAction(i18n(
"Add Curly Bracket"),
502 this, TQ_SLOT(addCurlyBracket()),
503 collection,
"formula_addcurbra");
504 m_addAbsAction =
new TDEAction(i18n(
"Add Abs"),
507 this, TQ_SLOT(addLineBracket()),
508 collection,
"formula_addabsbra");
510 m_addMatrixAction =
new TDEAction(i18n(
"Add Matrix..."),
513 this, TQ_SLOT(addMatrix()),
514 collection,
"formula_addmatrix");
516 m_addOneByTwoMatrixAction =
new TDEAction(i18n(
"Add 1x2 Matrix"),
519 this, TQ_SLOT(addOneByTwoMatrix()),
520 collection,
"formula_add_one_by_two_matrix");
523 m_addUpperLeftAction =
new TDEAction(i18n(
"Add Upper Left Index"),
526 this, TQ_SLOT(addUpperLeftIndex()),
527 collection,
"formula_addupperleft");
528 m_addLowerLeftAction =
new TDEAction(i18n(
"Add Lower Left Index"),
531 this, TQ_SLOT(addLowerLeftIndex()),
532 collection,
"formula_addlowerleft");
533 m_addUpperRightAction =
new TDEAction(i18n(
"Add Upper Right Index"),
536 this, TQ_SLOT(addUpperRightIndex()),
537 collection,
"formula_addupperright");
538 m_addLowerRightAction =
new TDEAction(i18n(
"Add Lower Right Index"),
541 this, TQ_SLOT(addLowerRightIndex()),
542 collection,
"formula_addlowerright");
544 m_addGenericUpperAction =
new TDEAction(i18n(
"Add Upper Index"),
547 this, TQ_SLOT(addGenericUpperIndex()),
548 collection,
"formula_addupperindex");
549 m_addGenericLowerAction =
new TDEAction(i18n(
"Add Lower Index"),
552 this, TQ_SLOT(addGenericLowerIndex()),
553 collection,
"formula_addlowerindex");
555 m_addOverlineAction =
new TDEAction(i18n(
"Add Overline"),
558 this, TQ_SLOT(addOverline()),
559 collection,
"formula_addoverline");
560 m_addUnderlineAction =
new TDEAction(i18n(
"Add Underline"),
563 this, TQ_SLOT(addUnderline()),
564 collection,
"formula_addunderline");
566 m_addMultilineAction =
new TDEAction(i18n(
"Add Multiline"),
569 this, TQ_SLOT(addMultiline()),
570 collection,
"formula_addmultiline");
572 m_removeEnclosingAction =
new TDEAction(i18n(
"Remove Enclosing Element"),
574 this, TQ_SLOT(removeEnclosing()),
575 collection,
"formula_removeenclosing");
577 m_makeGreekAction =
new TDEAction(i18n(
"Convert to Greek"),
579 this, TQ_SLOT(makeGreek()),
580 collection,
"formula_makegreek");
582 m_appendColumnAction =
new TDEAction( i18n(
"Append Column" ),
585 this, TQ_SLOT( appendColumn() ),
586 collection,
"formula_appendcolumn" );
587 m_insertColumnAction =
new TDEAction( i18n(
"Insert Column" ),
590 this, TQ_SLOT( insertColumn() ),
591 collection,
"formula_insertcolumn" );
592 m_removeColumnAction =
new TDEAction( i18n(
"Remove Column" ),
595 this, TQ_SLOT( removeColumn() ),
596 collection,
"formula_removecolumn" );
597 m_appendRowAction =
new TDEAction( i18n(
"Append Row" ),
600 this, TQ_SLOT( appendRow() ),
601 collection,
"formula_appendrow" );
602 m_insertRowAction =
new TDEAction( i18n(
"Insert Row" ),
605 this, TQ_SLOT( insertRow() ),
606 collection,
"formula_insertrow" );
607 m_removeRowAction =
new TDEAction( i18n(
"Remove Row" ),
610 this, TQ_SLOT( removeRow() ),
611 collection,
"formula_removerow" );
613 m_syntaxHighlightingAction =
new TDEToggleAction(i18n(
"Syntax Highlighting"),
615 this, TQ_SLOT(toggleSyntaxHighlighting()),
616 collection,
"formula_syntaxhighlighting");
619 m_formatBoldAction =
new TDEToggleAction( i18n(
"&Bold" ),
"format-text-bold",
621 this, TQ_SLOT( textBold() ),
622 collection,
"formula_format_bold" );
623 m_formatItalicAction =
new TDEToggleAction( i18n(
"&Italic" ),
"format-text-italic",
625 this, TQ_SLOT( textItalic() ),
626 collection,
"formula_format_italic" );
630 TQStringList delimiter;
631 delimiter.append(TQString(
"("));
632 delimiter.append(TQString(
"["));
633 delimiter.append(TQString(
"{"));
634 delimiter.append(TQString(
"<"));
635 delimiter.append(TQString(
"/"));
636 delimiter.append(TQString(
"\\"));
637 delimiter.append(TQString(
"|"));
638 delimiter.append(TQString(
" "));
639 delimiter.append(TQString(
")"));
640 delimiter.append(TQString(
"]"));
641 delimiter.append(TQString(
"}"));
642 delimiter.append(TQString(
">"));
644 0,
this, TQ_SLOT(delimiterLeft()),
645 collection,
"formula_typeleft");
650 delimiter.append(TQString(
")"));
651 delimiter.append(TQString(
"]"));
652 delimiter.append(TQString(
"}"));
653 delimiter.append(TQString(
">"));
654 delimiter.append(TQString(
"/"));
655 delimiter.append(TQString(
"\\"));
656 delimiter.append(TQString(
"|"));
657 delimiter.append(TQString(
" "));
658 delimiter.append(TQString(
"("));
659 delimiter.append(TQString(
"["));
660 delimiter.append(TQString(
"{"));
661 delimiter.append(TQString(
"<"));
663 0,
this, TQ_SLOT(delimiterRight()),
664 collection,
"formula_typeright");
665 m_rightBracket->
setItems(delimiter);
668 m_insertSymbolAction =
new TDEAction(i18n(
"Insert Symbol"),
671 this, TQ_SLOT(insertSymbol()),
672 collection,
"formula_insertsymbol");
673 m_symbolNamesAction =
new SymbolAction(i18n(
"Symbol Names"),
674 0,
this, TQ_SLOT(symbolNames()),
675 collection,
"formula_symbolnames");
678 ff.append( i18n(
"Normal" ) );
679 ff.append( i18n(
"Script" ) );
680 ff.append( i18n(
"Fraktur" ) );
681 ff.append( i18n(
"Double Struck" ) );
683 0,
this, TQ_SLOT(fontFamily()),
684 collection,
"formula_fontfamily");
689 et.append( i18n(
"Identifier" ) );
690 et.append( i18n(
"Operator" ) );
691 et.append( i18n(
"Number" ) );
692 et.append( i18n(
"Text" ) );
694 0,
this, TQ_SLOT( tokenElement() ),
695 collection,
"formula_tokenelement" );
701void DocumentWrapper::paste()
708void DocumentWrapper::copy()
715void DocumentWrapper::cut()
722void DocumentWrapper::undo()
727void DocumentWrapper::redo()
732void DocumentWrapper::addNegThinSpace()
735 SpaceRequest r( NEGTHIN );
736 formula()->performRequest( &r );
739void DocumentWrapper::addThinSpace()
742 SpaceRequest r( THIN );
743 formula()->performRequest( &r );
746void DocumentWrapper::addMediumSpace()
749 SpaceRequest r( MEDIUM );
750 formula()->performRequest( &r );
753void DocumentWrapper::addThickSpace()
756 SpaceRequest r( THICK );
757 formula()->performRequest( &r );
760void DocumentWrapper::addQuadSpace()
763 SpaceRequest r( QUAD );
764 formula()->performRequest( &r );
768void DocumentWrapper::addDefaultBracket()
771 BracketRequest r( m_leftBracketChar, m_rightBracketChar );
772 formula()->performRequest( &r );
776void DocumentWrapper::addBracket( SymbolType left, SymbolType right )
779 BracketRequest r( left, right );
780 formula()->performRequest( &r );
784void DocumentWrapper::addParenthesis()
787 BracketRequest r( LeftRoundBracket, RightRoundBracket );
788 formula()->performRequest( &r );
792void DocumentWrapper::addSquareBracket()
795 BracketRequest r( LeftSquareBracket, RightSquareBracket );
796 formula()->performRequest( &r );
800void DocumentWrapper::addCurlyBracket()
803 BracketRequest r( LeftCurlyBracket, RightCurlyBracket );
804 formula()->performRequest( &r );
808void DocumentWrapper::addLineBracket()
811 BracketRequest r( LeftLineBracket, RightLineBracket );
812 formula()->performRequest( &r );
816void DocumentWrapper::addFraction()
819 Request r( req_addFraction );
820 formula()->performRequest( &r );
824void DocumentWrapper::addRoot()
827 Request r( req_addRoot );
828 formula()->performRequest( &r );
832void DocumentWrapper::addIntegral()
835 SymbolRequest r( Integral );
836 formula()->performRequest( &r );
840void DocumentWrapper::addProduct()
843 SymbolRequest r( Product );
844 formula()->performRequest( &r );
848void DocumentWrapper::addSum()
851 SymbolRequest r( Sum );
852 formula()->performRequest( &r );
856void DocumentWrapper::addMatrix( uint rows, uint columns )
859 MatrixRequest r( rows, columns );
860 formula()->performRequest( &r );
864void DocumentWrapper::addOneByTwoMatrix()
867 Request r( req_addOneByTwoMatrix );
868 formula()->performRequest( &r );
872void DocumentWrapper::addNameSequence()
875 Request r( req_addNameSequence );
876 formula()->performRequest( &r );
880void DocumentWrapper::addLowerLeftIndex()
883 IndexRequest r( lowerLeftPos );
884 formula()->performRequest( &r );
888void DocumentWrapper::addUpperLeftIndex()
891 IndexRequest r( upperLeftPos );
892 formula()->performRequest( &r );
896void DocumentWrapper::addLowerRightIndex()
899 IndexRequest r( lowerRightPos );
900 formula()->performRequest( &r );
904void DocumentWrapper::addUpperRightIndex()
907 IndexRequest r( upperRightPos );
908 formula()->performRequest( &r );
912void DocumentWrapper::addGenericLowerIndex()
915 IndexRequest r( lowerMiddlePos );
916 formula()->performRequest( &r );
920void DocumentWrapper::addGenericUpperIndex()
923 IndexRequest r( upperMiddlePos );
924 formula()->performRequest( &r );
928void DocumentWrapper::addOverline()
931 Request r( req_addOverline );
932 formula()->performRequest( &r );
936void DocumentWrapper::addUnderline()
939 Request r( req_addUnderline );
940 formula()->performRequest( &r );
944void DocumentWrapper::addMultiline()
947 Request r( req_addMultiline );
948 formula()->performRequest( &r );
952void DocumentWrapper::removeEnclosing()
955 DirectedRemove r( req_removeEnclosing, beforeCursor );
956 formula()->performRequest( &r );
960void DocumentWrapper::makeGreek()
963 Request r( req_makeGreek );
964 formula()->performRequest( &r );
968void DocumentWrapper::insertSymbol()
971 m_document->m_contextStyle->
symbolTable().contains( m_selectedName ) ) {
973 if ( ch != TQChar::null ) {
974 TextCharRequest r( ch,
true );
975 formula()->performRequest( &r );
978 TextRequest r( m_selectedName );
979 formula()->performRequest( &r );
984void DocumentWrapper::insertSymbol( TQString name )
986 if ( hasFormula() ) {
987 if ( m_document->m_contextStyle->
symbolTable().contains( name ) ) {
989 if ( ch != TQChar::null ) {
990 TextCharRequest r( ch,
true );
991 formula()->performRequest( &r );
995 TextRequest r( name );
996 formula()->performRequest( &r );
1000void DocumentWrapper::appendColumn()
1002 if ( hasFormula() ) {
1003 Request r( req_appendColumn );
1004 formula()->performRequest( &r );
1008void DocumentWrapper::insertColumn()
1010 if ( hasFormula() ) {
1011 Request r( req_insertColumn );
1012 formula()->performRequest( &r );
1016void DocumentWrapper::removeColumn()
1018 if ( hasFormula() ) {
1019 Request r( req_removeColumn );
1020 formula()->performRequest( &r );
1024void DocumentWrapper::appendRow()
1026 if ( hasFormula() ) {
1027 Request r( req_appendRow );
1028 formula()->performRequest( &r );
1032void DocumentWrapper::insertRow()
1034 if ( hasFormula() ) {
1035 Request r( req_insertRow );
1036 formula()->performRequest( &r );
1040void DocumentWrapper::removeRow()
1042 if ( hasFormula() ) {
1043 Request r( req_removeRow );
1044 formula()->performRequest( &r );
1048void DocumentWrapper::toggleSyntaxHighlighting()
1050 m_document->m_contextStyle->setSyntaxHighlighting( m_syntaxHighlightingAction->
isChecked() );
1052 m_document->recalc();
1055void DocumentWrapper::textBold()
1057 if ( hasFormula() ) {
1058 CharStyleRequest r( req_formatBold,
1059 getFormatBoldAction()->isChecked(),
1060 getFormatItalicAction()->isChecked() );
1061 formula()->performRequest( &r );
1065void DocumentWrapper::textItalic()
1067 if ( hasFormula() ) {
1068 CharStyleRequest r( req_formatItalic,
1069 getFormatBoldAction()->isChecked(),
1070 getFormatItalicAction()->isChecked() );
1071 formula()->performRequest( &r );
1075void DocumentWrapper::delimiterLeft()
1078 switch ( left.at(0).latin1() ) {
1089 m_leftBracketChar =
static_cast<SymbolType
>( left.at(0).latin1() );
1092 m_leftBracketChar = LeftLineBracket;
1095 m_leftBracketChar = EmptyBracket;
1100void DocumentWrapper::delimiterRight()
1103 switch ( right.at(0).latin1() ) {
1114 m_rightBracketChar =
static_cast<SymbolType
>( right.at(0).latin1() );
1117 m_rightBracketChar = RightLineBracket;
1120 m_rightBracketChar = EmptyBracket;
1125void DocumentWrapper::symbolNames()
1127 m_selectedName = m_symbolNamesAction->currentText();
1131void DocumentWrapper::fontFamily()
1133 if ( hasFormula() ) {
1135 CharFamily cf = anyFamily;
1137 case 0: cf = normalFamily;
break;
1138 case 1: cf = scriptFamily;
break;
1139 case 2: cf = frakturFamily;
break;
1140 case 3: cf = doubleStruckFamily;
break;
1142 CharFamilyRequest r( cf );
1143 formula()->performRequest( &r );
1148void DocumentWrapper::tokenElement()
1150 if ( hasFormula() ) {
1152 TokenElementType te = anyElement;
1154 case 0: te = identifierElement;
break;
1155 case 1: te = operatorElement;
break;
1156 case 2: te = numberElement;
break;
1157 case 3: te = textElement;
break;
1159 TokenElementRequest r( te );
1160 formula()->performRequest( &r );
1165void DocumentWrapper::initSymbolNamesAction()
1167 if ( m_hasActions ) {
1169 TQStringList names = st.
allNames();
1170 TQFont font( m_document->m_contextStyle->getFontStyle() );
1171 TQMemArray<TQChar> chars( names.count() );
1174 for ( TQStringList::Iterator it = names.begin();
1177 chars[ i ] = st.
unicode( *it );
1179 m_symbolNamesAction->setSymbols( names, m_document->m_contextStyle->getMathFont(), chars );
1180 m_selectedName = names[0];
1187 kdDebug( DEBUGID ) <<
"DocumentWrapper::setEnabled " << enabled << endl;
1188 getAddNegThinSpaceAction()->
setEnabled( enabled );
1190 getAddGenericUpperAction()->
setEnabled( enabled );
1191 getAddGenericLowerAction()->
setEnabled( enabled );
1192 getAddOverlineAction()->
setEnabled( enabled );
1193 getAddUnderlineAction()->
setEnabled( enabled );
1194 getRemoveEnclosingAction()->
setEnabled( enabled );
1195 getInsertSymbolAction()->
setEnabled( enabled );
1196 getAddThinSpaceAction()->
setEnabled( enabled );
1197 getAddMediumSpaceAction()->
setEnabled( enabled );
1198 getAddThickSpaceAction()->
setEnabled( enabled );
1199 getAddQuadSpaceAction()->
setEnabled( enabled );
1200 getAddBracketAction()->
setEnabled( enabled );
1201 getAddSBracketAction()->
setEnabled( enabled );
1202 getAddCBracketAction()->
setEnabled( enabled );
1204 getAddFractionAction()->
setEnabled( enabled );
1207 getAddProductAction()->
setEnabled( enabled );
1208 getAddIntegralAction()->
setEnabled( enabled );
1210 getAddOneByTwoMatrixAction()->
setEnabled( enabled );
1211 getAddUpperLeftAction()->
setEnabled( enabled );
1212 getAddLowerLeftAction()->
setEnabled( enabled );
1213 getAddUpperRightAction()->
setEnabled( enabled );
1214 getAddLowerRightAction()->
setEnabled( enabled );
1216 getAddGenericUpperAction()->
setEnabled( enabled );
1217 getAddGenericLowerAction()->
setEnabled( enabled );
1221 getAddGenericUpperAction()->
1222 setShortcut( TDEShortcut( CTRL + Key_U ) );
1223 getAddGenericLowerAction()->
1224 setShortcut( TDEShortcut( CTRL + Key_L ) );
1225 getRemoveEnclosingAction()->
1226 setShortcut( TDEShortcut( CTRL + Key_R ) );
1227 getMakeGreekAction()->
1228 setShortcut( TDEShortcut( CTRL + Key_G ) );
1229 getInsertSymbolAction()->
1230 setShortcut( TDEShortcut( CTRL + Key_I ) );
1231 getAddOverlineAction()->
1232 setShortcut( TDEShortcut( CTRL + SHIFT + Key_O ) );
1233 getAddUnderlineAction()->
1234 setShortcut( TDEShortcut( CTRL + SHIFT + Key_U ) );
1235 getAddBracketAction()->
1236 setShortcut( TDEShortcut( CTRL + SHIFT + Key_B ) );
1237 getAddSBracketAction()->
1238 setShortcut( TDEShortcut( CTRL + SHIFT + Key_D ) );
1239 getAddCBracketAction()->
1240 setShortcut( TDEShortcut( CTRL + SHIFT + Key_C ) );
1242 setShortcut( TDEShortcut( CTRL + SHIFT + Key_A ) );
1243 getAddFractionAction()->
1244 setShortcut( TDEShortcut( CTRL + SHIFT + Key_F ) );
1245 getAddRootAction()->
1246 setShortcut( TDEShortcut( CTRL + SHIFT + Key_R ) );
1248 setShortcut( TDEShortcut( CTRL + SHIFT + Key_S ) );
1249 getAddProductAction()->
1250 setShortcut( TDEShortcut( CTRL + SHIFT + Key_P ) );
1251 getAddIntegralAction()->
1252 setShortcut( TDEShortcut( CTRL + SHIFT + Key_I ) );
1253 getAddMatrixAction()->
1254 setShortcut( TDEShortcut( CTRL + SHIFT + Key_M ) );
1258 getAddGenericUpperAction()->
setShortcut( TDEShortcut() );
1259 getAddGenericLowerAction()->
setShortcut( TDEShortcut() );
1260 getRemoveEnclosingAction()->
setShortcut( TDEShortcut() );
1261 getMakeGreekAction()->
setShortcut( TDEShortcut() );
1262 getInsertSymbolAction()->
setShortcut( TDEShortcut() );
1263 getAddOverlineAction()->
setShortcut( TDEShortcut() );
1264 getAddUnderlineAction()->
setShortcut( TDEShortcut() );
1265 getAddBracketAction()->
setShortcut( TDEShortcut() );
1266 getAddSBracketAction()->
setShortcut( TDEShortcut() );
1267 getAddCBracketAction()->
setShortcut( TDEShortcut() );
1269 getAddFractionAction()->
setShortcut( TDEShortcut() );
1272 getAddProductAction()->
setShortcut( TDEShortcut() );
1273 getAddIntegralAction()->
setShortcut( TDEShortcut() );
1274 getAddMatrixAction()->
setShortcut( TDEShortcut() );
1278void DocumentWrapper::enableMatrixActions(
bool b)
1288void DocumentWrapper::updateConfig()
1290 m_syntaxHighlightingAction->
1291 setChecked( m_document->m_contextStyle->syntaxHighlighting() );
1292 initSymbolNamesAction();
1296KFORMULA_NAMESPACE_END
1298using namespace KFormula;
1299#include "kformuladocument.moc"
void copy()
Copy the current selection to the clipboard.
void paste()
Insert data from the clipboard.
void initialize()
Needs to be called before anything else can be done with a newly created formula! This is required to...
bool load(const TQDomElement &fe)
Loads a formula from the document.
void cut()
Copy and remove.
FormulaCursor * activeCursor()
Contains all the style information for the formela.
void init(bool init=true)
void setZoomAndResolution(int zoom, int dpiX, int dpiY)
Change the zoom factor to z (e.g.
void readConfig(TDEConfig *config, bool init=true)
const SymbolTable & symbolTable() const
A Wrapper that constracts the actions and must be given a real document to work with.
void setEnabled(bool enabled)
Enables our action according to enabled.
Document * document() const
A document that can contain a lot of formulas (container).
Document(TQObject *parent=0, const char *name=0, const TQStringList &args=TQStringList())
Creates a formula document.
void setEnabled(bool enabled)
Enables our action according to enabled.
void updateConfig()
Gets called when the configuration changed.
bool loadOasis(const TQDomDocument &doc)
Load a OASIS content.xml DomDocument.
KoCommandHistory * getHistory() const
virtual Container * createFormula(int pos=-1, bool registerMe=true)
Factory method.
void activate(Container *formula)
Sets a new formula.
Container * formulaAt(uint pos)
bool loadDocumentPart(TQDomElement node)
Load the document settings.
virtual void unregisterFormula(Container *)
Removes a formula from this document.
void sortFormulaList()
Sorts the list of formulas according to their screen positions.
int formulaPos(Container *formula)
ContextStyle & getContextStyle(bool edit=false)
TQDomDocument createMathMLDomDocument()
Create a MathML Dom Document, deprecates KFO Dom Document for internal layout TODO: Shouldn't this go...
TQDomDocument saveXML()
Save the document with all its formulae.
const SymbolTable & getSymbolTable() const
static TQDomDocument createDomDocument()
Return a kformula DomDocument.
bool loadXML(const TQDomDocument &doc)
Load a kformula DomDocument with all its formulas.
TQPtrListIterator< Container > formulas()
virtual void registerFormula(Container *, int pos=-1)
Registers a new formula to be part of this document.
void setCreationStrategy(TQString strategy)
Set formula creation strategy: old KFormula or MathML/ODF.
TQDomElement saveDocumentPart(TQDomDocument &doc)
Save the document settings.
void setZoomAndResolution(int zoom, int dpiX, int dpiY)
Change the zoom factor to z (e.g.
The command history stores a (user) configurable amount of Commands.
virtual void redo()
Redoes the last undone action.
virtual void undo()
Undoes the last action.
TQDomDocument createDomDocument(const TQString &tagName, const TQString &version) const
Return a correctly created TQDomDocument for this KoDocument, including processing instruction,...
double zoomedResolutionX() const
The strategy to be used for OASIS OpenDocument / MathML.
The ordinary strategy to be used for plain kformula.
TQStringList allNames() const
TQChar unicode(TQString name) const
virtual bool setShortcut(const TDEShortcut &)
virtual void setEnabled(bool enable)
virtual TQString currentText() const
virtual void setItems(const TQStringList &lst)
virtual int currentItem() const
virtual void setChecked(bool)