diff options
34 files changed, 4169 insertions, 337 deletions
diff --git a/xmloff/dtd/office.mod b/xmloff/dtd/office.mod index 25642b8f5b4c..b0b75564b25a 100644 --- a/xmloff/dtd/office.mod +++ b/xmloff/dtd/office.mod @@ -1,5 +1,5 @@ <!-- - $Id: office.mod,v 1.6 2000-11-01 11:55:17 dr Exp $ + $Id: office.mod,v 1.7 2000-11-02 15:51:17 dvo Exp $ The Contents of this file are made available subject to the terms of either of the following licenses @@ -126,7 +126,7 @@ <!ENTITY % body "(%text-decls;,table:content-validations?,table:label-ranges?, (text:h|text:p|text:ordered-list| text:unordered-list|table:table|chart:chart|draw:page| - draw:a|draw:text-box|draw:image|text:section)*, + draw:a|draw:text-box|draw:image|text:section|text:table-of-content)*, table:named-expressions?, table:database-ranges?,table:data-pilot-tables?, table:consolidation?)"> diff --git a/xmloff/dtd/text.mod b/xmloff/dtd/text.mod index 470955a3ed24..01e424c623ad 100644 --- a/xmloff/dtd/text.mod +++ b/xmloff/dtd/text.mod @@ -1,5 +1,5 @@ <!-- - $Id: text.mod,v 1.5 2000-10-31 09:40:33 dvo Exp $ + $Id: text.mod,v 1.6 2000-11-02 15:51:17 dvo Exp $ The Contents of this file are made available subject to the terms of either of the following licenses @@ -124,7 +124,7 @@ <!ENTITY % inline-text "(#PCDATA| text:span|text:tab-stop|text:s|text:line-break| - text:footnote|text:endnote| + text:footnote|text:endnote|text:a| text:bookmark|text:bookmark-start|text:bookmark-end| text:reference-mark|text:reference-mark-start| text:reference-mark-end|%fields;| @@ -143,6 +143,17 @@ <!ELEMENT text:span %inline-text;> <!ATTLIST text:span text:style-name %styleName; #REQUIRED> +<!ELEMENT text:a %inline-text;> +<!ATTLIST text:a xlink:href %uriReference; #REQUIRED> +<!ATTLIST text:a xlink:type (simple) #FIXED "simple"> +<!ATTLIST text:a xlink:actuate (onRequest) "onRequest"> +<!ATTLIST text:a xlink:show (new|replace) "replace"> +<!ATTLIST text:a office:name %string; #IMPLIED> +<!ATTLIST text:a office:target-frame-name %string; #IMPLIED> +<!ATTLIST text:a text:style-name %styleName; #IMPLIED> +<!ATTLIST text:a text:visited-style-name %styleName; #IMPLIED> + + <!ELEMENT text:s EMPTY> <!ATTLIST text:s text:c %positiveInteger; "1"> @@ -622,10 +633,14 @@ <!ELEMENT text:endnote-body (text:h|text:p| text:ordered-list|text:unordered-list)*> -<!ELEMENT text:section ((text:section-source|text:section-source-dde)?, +<!ENTITY % sectionText "((text:section-source|text:section-source-dde)?, (text:h|text:p|text:ordered-list| text:unordered-list|table:table|chart:chart|draw:page| - draw:a|draw:text-box|draw:image|text:section)*)> + draw:a|draw:text-box|draw:image|text:section| + text:table-of-content)*)"> + +<!ELEMENT text:section %sectionText; > + <!ATTLIST text:section text:name CDATA #REQUIRED> <!ATTLIST text:section text:style-name %styleName; #IMPLIED> <!ATTLIST text:section text:protected %boolean; "false"> @@ -643,3 +658,62 @@ <!ATTLIST text:section-source-dde text:dde-application CDATA #IMPLIED> <!ATTLIST text:section-source-dde text:dde-topic CDATA #IMPLIED> <!ATTLIST text:section-source-dde text:dde-item CDATA #IMPLIED> + +<!ELEMENT text:table-of-content (text:table-of-content-source, + text:table-of-content-body) > +<!ATTLIST text:table-of-content text:style-name %styleName; #IMPLIED> + +<!ELEMENT text:table-of-content-body %sectionText; > + +<!ELEMENT text:table-of-content-source (text:index-title-template | + text:index-entry-template | + text:index-source-styles)* > +<!ATTLIST text:table-of-content-source text:outline-level %integer; #IMPLIED> +<!ATTLIST text:table-of-content-source text:use-index-marks %boolean; "true"> +<!ATTLIST text:table-of-content-source text:index-scope (document|chapter) + "document"> +<!ATTLIST text:table-of-content-source text:relative-tab-stop-position + %boolean; "true"> + +<!ELEMENT text:index-title-template (#PCDATA)> +<!ATTLIST text:index-title-template text:style-name %styleName; #IMPLIED> + +<!ELEMENT text:index-entry-template (text:index-entry-chapter | + text:index-entry-page-number | + text:index-entry-text | + text:index-entry-span | + text:index-entry-tab-stop | + text:index-entry-link-start | + text:index-entry-link-end )* > +<!ATTLIST text:index-entry-template text:outline-level %integer; #REQUIRED> +<!ATTLIST text:index-entry-template text:style-name %styleName; #REQUIRED> + +<!ELEMENT text:index-entry-chapter EMPTY> +<!ATTLIST text:index-entry-chapter text:style-name %styleName; #IMPLIED> + +<!ELEMENT text:index-entry-text EMPTY> +<!ATTLIST text:index-entry-text text:style-name %styleName; #IMPLIED> + +<!ELEMENT text:index-entry-page-number EMPTY> +<!ATTLIST text:index-entry-page-number text:style-name %styleName; #IMPLIED> + +<!ELEMENT text:index-entry-span (#PCDATA)> +<!ATTLIST text:index-entry-span text:style-name %styleName; #IMPLIED> + +<!ELEMENT text:index-entry-tab-stop EMPTY> +<!ATTLIST text:index-entry-tab-stop text:style-name %styleName; #IMPLIED> +<!ATTLIST text:index-entry-tab-stop style:leader-char %character; " "> +<!ATTLIST text:index-entry-tab-stop style:type (left|right) "left"> +<!ATTLIST text:index-entry-tab-stop style:position %length; #IMPLIED> + +<!ELEMENT text:index-entry-link-start EMPTY> +<!ATTLIST text:index-entry-link-start text:style-name %styleName; #IMPLIED> + +<!ELEMENT text:index-entry-link-end EMPTY> +<!ATTLIST text:index-entry-link-end text:style-name %styleName; #IMPLIED> + +<!ELEMENT text:index-source-styles (text:index-source-style)*> +<!ATTLIST text:index-source-styles text:outline-level %integer; #REQUIRED> + +<!ELEMENT text:index-source-style EMPTY> +<!ATTLIST text:index-source-style text:style-name %styleName; #REQUIRED> diff --git a/xmloff/inc/txtflde.hxx b/xmloff/inc/txtflde.hxx index 4cf5fb04f3a4..bd07d2e6a8cb 100644 --- a/xmloff/inc/txtflde.hxx +++ b/xmloff/inc/txtflde.hxx @@ -2,9 +2,9 @@ * * $RCSfile: txtflde.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: dvo $ $Date: 2000-10-20 12:45:05 $ + * last change: $Author: dvo $ $Date: 2000-11-02 15:51:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -155,6 +155,7 @@ enum FieldIdEnum { FIELD_ID_DDE, // DDE field FIELD_ID_SHEET_NAME, // name of current (spread-)sheet + FIELD_ID_URL, // URL field (only Calc, Draw, Impress) FIELD_ID_UNKNOWN // invalid or unknown field type! }; @@ -413,6 +414,8 @@ private: const ::rtl::OUString sPropertyDDECommandFile; const ::rtl::OUString sPropertyDDECommandElement; const ::rtl::OUString sPropertySequenceValue; + const ::rtl::OUString sPropertyURL; + const ::rtl::OUString sPropertyTargetFrame; const ::rtl::OUString sEmpty; }; diff --git a/xmloff/inc/txtfldi.hxx b/xmloff/inc/txtfldi.hxx index fdc39d6b432b..792468bf6f72 100644 --- a/xmloff/inc/txtfldi.hxx +++ b/xmloff/inc/txtfldi.hxx @@ -2,9 +2,9 @@ * * $RCSfile: txtfldi.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: dvo $ $Date: 2000-10-20 12:45:05 $ + * last change: $Author: dvo $ $Date: 2000-11-02 15:51:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -156,6 +156,9 @@ enum XMLTextFieldAttrTokens XML_TOK_TEXTFIELD_REF_NAME, XML_TOK_TEXTFIELD_CONNECTION_NAME, + XML_TOK_TEXTFIELD_HREF, + XML_TOK_TEXTFIELD_TARGET_FRAME, + XML_TOK_TEXTFIELD_UNKNOWN }; @@ -1246,5 +1249,37 @@ protected: ::com::sun::star::beans::XPropertySet> & xPropertySet); }; +/** import hyperlinks as URL fields (Calc, Impress, Draw) (<office:a>) */ +class XMLUrlFieldImportContext : public XMLTextFieldImportContext +{ + + const ::rtl::OUString sPropertyURL; + const ::rtl::OUString sPropertyTargetFrame; + + ::rtl::OUString sURL; + ::rtl::OUString sFrame; + sal_Bool bFrameOK; + +public: + + TYPEINFO(); + + XMLUrlFieldImportContext(SvXMLImport& rImport, + XMLTextImportHelper& rHlp, + sal_uInt16 nPrfx, + const ::rtl::OUString& sLocalName); + +protected: + + /// no attributes -> empty method + virtual void ProcessAttribute( sal_uInt16 nAttrToken, + const ::rtl::OUString& sAttrValue ); + + /// no atributes -> empty method + virtual void PrepareField( + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet> & xPropertySet); +}; + #endif diff --git a/xmloff/inc/xmlkywd.hxx b/xmloff/inc/xmlkywd.hxx index f2da98ef5dc0..fd2eb2799277 100644 --- a/xmloff/inc/xmlkywd.hxx +++ b/xmloff/inc/xmlkywd.hxx @@ -2,9 +2,9 @@ * * $RCSfile: xmlkywd.hxx,v $ * - * $Revision: 1.29 $ + * $Revision: 1.30 $ * - * last change: $Author: dr $ $Date: 2000-11-02 13:42:37 $ + * last change: $Author: dvo $ $Date: 2000-11-02 15:51:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -277,14 +277,14 @@ XML_CONSTASCII_ACTION( sXML_connect_bars, "connect-bars" ); XML_CONSTASCII_ACTION( sXML_connection_name, "connection-name" ); XML_CONSTASCII_ACTION( sXML_connector, "connector" ); XML_CONSTASCII_ACTION( sXML_consolidation, "consolidation" ); -XML_CONSTASCII_ACTION( sXML_continue, "continue" ); XML_CONSTASCII_ACTION( sXML_consecutive_numbering, "consecutive-numbering" ); XML_CONSTASCII_ACTION( sXML_constant, "constant" ); XML_CONSTASCII_ACTION( sXML_contains_header, "contains-header"); XML_CONSTASCII_ACTION( sXML_content, "content" ); XML_CONSTASCII_ACTION( sXML_content_validation, "content-validation"); -XML_CONSTASCII_ACTION( sXML_content_validations, "content-validations"); XML_CONSTASCII_ACTION( sXML_content_validation_name, "validation-name"); +XML_CONSTASCII_ACTION( sXML_content_validations, "content-validations"); +XML_CONSTASCII_ACTION( sXML_continue, "continue" ); XML_CONSTASCII_ACTION( sXML_continue_numbering, "continue-numbering" ); XML_CONSTASCII_ACTION( sXML_contrast , "contrast" ); XML_CONSTASCII_ACTION( sXML_control, "control" ); @@ -557,6 +557,19 @@ XML_CONSTASCII_ACTION( sXML_ignore_empty_rows, "ignore-empty-rows"); XML_CONSTASCII_ACTION( sXML_image, "image" ); XML_CONSTASCII_ACTION( sXML_image_count, "image-count" ); XML_CONSTASCII_ACTION( sXML_index, "index"); +XML_CONSTASCII_ACTION( sXML_index_entry_bibliography, "index-entry-bibliography" ); +XML_CONSTASCII_ACTION( sXML_index_entry_chapter, "index-entry-chapter" ); +XML_CONSTASCII_ACTION( sXML_index_entry_link_end, "index-entry-link-end" ); +XML_CONSTASCII_ACTION( sXML_index_entry_link_start, "index-entry-link-start" ); +XML_CONSTASCII_ACTION( sXML_index_entry_page_number, "index-entry-page-number" ); +XML_CONSTASCII_ACTION( sXML_index_entry_span, "index-entry-span" ); +XML_CONSTASCII_ACTION( sXML_index_entry_tab_stop, "index-entry-tab-stop" ); +XML_CONSTASCII_ACTION( sXML_index_entry_template, "index-entry-template" ); +XML_CONSTASCII_ACTION( sXML_index_entry_text, "index-entry-text" ); +XML_CONSTASCII_ACTION( sXML_index_scope, "index-scope" ); +XML_CONSTASCII_ACTION( sXML_index_source_styles, "index-source-styles" ); +XML_CONSTASCII_ACTION( sXML_index_source_style, "index-source-style" ); +XML_CONSTASCII_ACTION( sXML_index_title_template, "index-title-template" ); XML_CONSTASCII_ACTION( sXML_information, "information" ); XML_CONSTASCII_ACTION( sXML_initial_creator, "initial-creator" ); XML_CONSTASCII_ACTION( sXML_inset, "inset" ); @@ -583,6 +596,7 @@ XML_CONSTASCII_ACTION( sXML_landscape, "landscape" ); XML_CONSTASCII_ACTION( sXML_language, "language" ); XML_CONSTASCII_ACTION( sXML_last_column_spanned, "last-column-spanned" ); XML_CONSTASCII_ACTION( sXML_last_row_spanned, "last-row-spanned" ); +XML_CONSTASCII_ACTION( sXML_leader_char, "leader-char" ); XML_CONSTASCII_ACTION( sXML_left, "left" ); XML_CONSTASCII_ACTION( sXML_legend, "legend" ); XML_CONSTASCII_ACTION( sXML_legend_position, "legend-position" ); @@ -837,6 +851,7 @@ XML_CONSTASCII_ACTION( sXML_register_true, "register-true" ); XML_CONSTASCII_ACTION( sXML_rel_column_width, "rel-column-width" ); XML_CONSTASCII_ACTION( sXML_rel_width, "rel-width" ); XML_CONSTASCII_ACTION( sXML_relative, "relative" ) ; +XML_CONSTASCII_ACTION( sXML_relative_tab_stop_position, "relative-tab-stop-position" ); XML_CONSTASCII_ACTION( sXML_repeat, "repeat" ); XML_CONSTASCII_ACTION( sXML_repeat_column, "repeat-column"); XML_CONSTASCII_ACTION( sXML_repeat_row, "repeat-row"); @@ -874,10 +889,10 @@ XML_CONSTASCII_ACTION( sXML_score_spaces, "score-spaces" ); XML_CONSTASCII_ACTION( sXML_script, "script" ); XML_CONSTASCII_ACTION( sXML_seconds, "seconds" ); XML_CONSTASCII_ACTION( sXML_section, "section" ); -XML_CONSTASCII_ACTION( sXML_section_source, "section-source" ); -XML_CONSTASCII_ACTION( sXML_section_source_dde, "section-source-dde" ); XML_CONSTASCII_ACTION( sXML_section_desc, "section-desc" ); XML_CONSTASCII_ACTION( sXML_section_name, "section-name" ); +XML_CONSTASCII_ACTION( sXML_section_source, "section-source" ); +XML_CONSTASCII_ACTION( sXML_section_source_dde, "section-source-dde" ); XML_CONSTASCII_ACTION( sXML_select_page, "select-page" ); XML_CONSTASCII_ACTION( sXML_semi_automatic, "semi-automatic" ); XML_CONSTASCII_ACTION( sXML_sender_city, "sender-city" ); @@ -964,8 +979,8 @@ XML_CONSTASCII_ACTION( sXML_stroke , "stroke" ); XML_CONSTASCII_ACTION( sXML_stroke_color , "stroke-color" ); XML_CONSTASCII_ACTION( sXML_stroke_dasharray , "stroke-dasharray" ); XML_CONSTASCII_ACTION( sXML_stroke_linejoin , "stroke-linejoin" ); -XML_CONSTASCII_ACTION( sXML_stroke_width, "stroke-width" ); XML_CONSTASCII_ACTION( sXML_stroke_opacity, "stroke-opacity" ); +XML_CONSTASCII_ACTION( sXML_stroke_width, "stroke-width" ); XML_CONSTASCII_ACTION( sXML_style, "style" ); XML_CONSTASCII_ACTION( sXML_style_name, "style-name" ); XML_CONSTASCII_ACTION( sXML_styles, "styles" ); @@ -982,6 +997,7 @@ XML_CONSTASCII_ACTION( sXML_swiss, "swiss" ); XML_CONSTASCII_ACTION( sXML_symbol, "symbol" ); XML_CONSTASCII_ACTION( sXML_system, "system" ); XML_CONSTASCII_ACTION( sXML_tab_stop, "tab-stop" ); +XML_CONSTASCII_ACTION( sXML_tab_stops, "tab-stops" ); XML_CONSTASCII_ACTION( sXML_table, "table" ); XML_CONSTASCII_ACTION( sXML_table_cell, "table-cell" ); XML_CONSTASCII_ACTION( sXML_table_column, "table-column" ); @@ -992,16 +1008,13 @@ XML_CONSTASCII_ACTION( sXML_table_header, "table-header" ); XML_CONSTASCII_ACTION( sXML_table_header_columns, "table-header-columns" ); XML_CONSTASCII_ACTION( sXML_table_header_rows, "table-header-rows" ); XML_CONSTASCII_ACTION( sXML_table_name, "table-name"); +XML_CONSTASCII_ACTION( sXML_table_of_content, "table-of-content" ); +XML_CONSTASCII_ACTION( sXML_table_of_content_body, "table-of-content-body" ); +XML_CONSTASCII_ACTION( sXML_table_of_content_source, "table-of-content-source" ); XML_CONSTASCII_ACTION( sXML_table_page, "table-page" ); XML_CONSTASCII_ACTION( sXML_table_row, "table-row" ); XML_CONSTASCII_ACTION( sXML_table_row_group, "table-row-group" ); XML_CONSTASCII_ACTION( sXML_table_rows, "table-rows" ); -XML_CONSTASCII_ACTION( sXML_tabstop_char, "char" ); -XML_CONSTASCII_ACTION( sXML_tabstop_leader, "leader-char" ); -XML_CONSTASCII_ACTION( sXML_tabstop_position, "position" ); -XML_CONSTASCII_ACTION( sXML_tabstop_tab_stop, "tab-stop" ); -XML_CONSTASCII_ACTION( sXML_tabstop_tab_stops, "tab-stops" ); -XML_CONSTASCII_ACTION( sXML_tabstop_type, "type" ); XML_CONSTASCII_ACTION( sXML_target_cell_address, "target-cell-address"); XML_CONSTASCII_ACTION( sXML_target_frame_name, "target-frame-name" ); XML_CONSTASCII_ACTION( sXML_target_range_address, "target-range-address"); @@ -1068,6 +1081,7 @@ XML_CONSTASCII_ACTION( sXML_underline_small_wave, "small-wave" ); XML_CONSTASCII_ACTION( sXML_underline_wave, "wave" ); XML_CONSTASCII_ACTION( sXML_unordered_list, "unordered-list" ); XML_CONSTASCII_ACTION( sXML_use_cell_protection, "use-cell-protection" ); +XML_CONSTASCII_ACTION( sXML_use_index_marks, "use-index-marks" ); XML_CONSTASCII_ACTION( sXML_use_label, "use-label" ); XML_CONSTASCII_ACTION( sXML_use_optimal_column_width, "use-optimal-column-width"); XML_CONSTASCII_ACTION( sXML_use_optimal_row_height, "use-optimal-row-height"); @@ -1123,9 +1137,9 @@ XML_CONSTASCII_ACTION( sXML_width, "width" ); XML_CONSTASCII_ACTION( sXML_word, "word" ); XML_CONSTASCII_ACTION( sXML_word_count, "word-count" ); XML_CONSTASCII_ACTION( sXML_wrap, "wrap" ); -XML_CONSTASCII_ACTION( sXML_wrap_option, "wrap-option" ); XML_CONSTASCII_ACTION( sXML_wrap_contour, "wrap-contour" ); XML_CONSTASCII_ACTION( sXML_wrap_contour_mode, "wrap-contour-mode" ); +XML_CONSTASCII_ACTION( sXML_wrap_option, "wrap-option" ); XML_CONSTASCII_ACTION( sXML_x, "x" ); XML_CONSTASCII_ACTION( sXML_x1, "x1" ); XML_CONSTASCII_ACTION( sXML_x2, "x2" ); diff --git a/xmloff/source/style/xmltabe.cxx b/xmloff/source/style/xmltabe.cxx index 1de5287c8a34..9031812aaddd 100644 --- a/xmloff/source/style/xmltabe.cxx +++ b/xmloff/source/style/xmltabe.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmltabe.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-09-18 17:07:06 $ + * last change: $Author: dvo $ $Date: 2000-11-02 15:51:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -117,7 +117,7 @@ void SvxXMLTabStopExport::exportTabStop( const ::com::sun::star::style::TabStop* // position attribute mrUnitConv.convertMeasure( sBuffer, pTabStop->Position ); - AddAttribute( XML_NAMESPACE_STYLE, sXML_tabstop_position, + AddAttribute( XML_NAMESPACE_STYLE, sXML_position, sBuffer.makeStringAndClear() ); // type attribute @@ -125,7 +125,7 @@ void SvxXMLTabStopExport::exportTabStop( const ::com::sun::star::style::TabStop* { mrUnitConv.convertEnum( sBuffer, pTabStop->Alignment, psXML_tabstop_style ); - AddAttribute( XML_NAMESPACE_STYLE, sXML_tabstop_type, + AddAttribute( XML_NAMESPACE_STYLE, sXML_type, sBuffer.makeStringAndClear() ); } @@ -133,7 +133,7 @@ void SvxXMLTabStopExport::exportTabStop( const ::com::sun::star::style::TabStop* if( style::TabAlign_DECIMAL == pTabStop->Alignment ) { sBuffer.append( pTabStop->DecimalChar ); - AddAttribute( XML_NAMESPACE_STYLE, sXML_tabstop_char, + AddAttribute( XML_NAMESPACE_STYLE, sXML_char, sBuffer.makeStringAndClear() ); } @@ -141,11 +141,11 @@ void SvxXMLTabStopExport::exportTabStop( const ::com::sun::star::style::TabStop* if( ' ' != pTabStop->FillChar ) { sBuffer.append( pTabStop->FillChar ); - AddAttribute( XML_NAMESPACE_STYLE, sXML_tabstop_leader, + AddAttribute( XML_NAMESPACE_STYLE, sXML_leader_char, sBuffer.makeStringAndClear() ); } - OUString sElem = GetQNameByKey( XML_NAMESPACE_STYLE, OUString::createFromAscii(sXML_tabstop_tab_stop) ); + OUString sElem = GetQNameByKey( XML_NAMESPACE_STYLE, OUString::createFromAscii(sXML_tab_stop) ); mxHandler->ignorableWhitespace( msWS ); mxHandler->startElement( sElem, mxAttrList ); ClearAttrList(); @@ -225,7 +225,7 @@ void SvxXMLTabStopExport::Export( const uno::Any& rAny, return; OUString sElem = GetQNameByKey( XML_NAMESPACE_STYLE, - OUString::createFromAscii(sXML_tabstop_tab_stops) ); + OUString::createFromAscii(sXML_tab_stops) ); mxHandler->ignorableWhitespace( msWS ); mxHandler->startElement( sElem, mxAttrList ); ClearAttrList(); diff --git a/xmloff/source/style/xmltabi.cxx b/xmloff/source/style/xmltabi.cxx index 69d05d781366..d3f5372c8e48 100644 --- a/xmloff/source/style/xmltabi.cxx +++ b/xmloff/source/style/xmltabi.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmltabi.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: mib $ $Date: 2000-09-21 09:46:22 $ + * last change: $Author: dvo $ $Date: 2000-11-02 15:51:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -112,10 +112,10 @@ enum SvXMLTokenMapAttrs static __FAR_DATA SvXMLTokenMapEntry aTabsAttributesAttrTokenMap[] = { - { XML_NAMESPACE_STYLE, sXML_tabstop_position, XML_TOK_TABSTOP_POSITION }, - { XML_NAMESPACE_STYLE, sXML_tabstop_type, XML_TOK_TABSTOP_TYPE }, - { XML_NAMESPACE_STYLE, sXML_tabstop_char, XML_TOK_TABSTOP_CHAR }, - { XML_NAMESPACE_STYLE, sXML_tabstop_leader, XML_TOK_TABSTOP_LEADER }, + { XML_NAMESPACE_STYLE, sXML_position, XML_TOK_TABSTOP_POSITION }, + { XML_NAMESPACE_STYLE, sXML_type, XML_TOK_TABSTOP_TYPE }, + { XML_NAMESPACE_STYLE, sXML_char, XML_TOK_TABSTOP_CHAR }, + { XML_NAMESPACE_STYLE, sXML_leader_char, XML_TOK_TABSTOP_LEADER }, XML_TOKEN_MAP_END }; @@ -263,7 +263,7 @@ SvXMLImportContext *SvxXMLTabStopImportContext::CreateChildContext( SvXMLImportContext *pContext = 0; if( XML_NAMESPACE_STYLE == nPrefix && - 0 == rLocalName.equalsAsciiL( sXML_tabstop_tab_stop , sizeof( sXML_tabstop_tab_stop ) ) ) + 0 == rLocalName.equalsAsciiL( sXML_tab_stop , sizeof( sXML_tab_stop ) ) ) { // create new tabstop import context SvxXMLTabStopContext_Impl *pTabStopContext = diff --git a/xmloff/source/text/XMLIndexSimpleEntryContext.cxx b/xmloff/source/text/XMLIndexSimpleEntryContext.cxx new file mode 100644 index 000000000000..a7ab26dd269c --- /dev/null +++ b/xmloff/source/text/XMLIndexSimpleEntryContext.cxx @@ -0,0 +1,194 @@ +/************************************************************************* + * + * $RCSfile: XMLIndexSimpleEntryContext.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dvo $ $Date: 2000-11-02 15:51:18 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +#ifndef _XMLOFF_XMLINDEXSIMPLEENTRYCONTEXT_HXX_ +#include "XMLIndexSimpleEntryContext.hxx" +#endif + +#ifndef _XMLOFF_XMLINDEXTEMPLATECONTEXT_HXX_ +#include "XMLIndexTemplateContext.hxx" +#endif + +#ifndef _XMLOFF_XMLICTXT_HXX +#include "xmlictxt.hxx" +#endif + +#ifndef _XMLOFF_XMLIMP_HXX +#include "xmlimp.hxx" +#endif + +#ifndef _XMLOFF_TEXTIMP_HXX_ +#include "txtimp.hxx" +#endif + +#ifndef _XMLOFF_NMSPMAP_HXX +#include "nmspmap.hxx" +#endif + +#ifndef _XMLOFF_XMLNMSPE_HXX +#include "xmlnmspe.hxx" +#endif + +#ifndef _XMLOFF_XMLKYWD_HXX +#include "xmlkywd.hxx" +#endif + +#ifndef _XMLOFF_XMLUCONV_HXX +#include "xmluconv.hxx" +#endif + + +//using namespace ::com::sun::star::text; + +using ::rtl::OUString; +using ::com::sun::star::beans::PropertyValue; +using ::com::sun::star::beans::PropertyValues; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::Any; +using ::com::sun::star::xml::sax::XAttributeList; + + +const sal_Char sAPI_TokenType[] = "TokenType"; +const sal_Char sAPI_CharacterStyleName[] = "CharacterStyleName"; + +TYPEINIT1( XMLIndexSimpleEntryContext, SvXMLImportContext); + +XMLIndexSimpleEntryContext::XMLIndexSimpleEntryContext( + SvXMLImport& rImport, + const OUString& rEntry, + XMLIndexTemplateContext& rTemplate, + sal_uInt16 nPrfx, + const OUString& rLocalName ) : + SvXMLImportContext(rImport, nPrfx, rLocalName), + rTemplateContext(rTemplate), + rEntryType(rEntry), + sCharStyleName(), + bCharStyleNameOK(sal_False), + nValues(1) +{ +} + +XMLIndexSimpleEntryContext::~XMLIndexSimpleEntryContext() +{ +} + +void XMLIndexSimpleEntryContext::StartElement( + const Reference<XAttributeList> & xAttrList) +{ + // we know only one attribute: style-name + sal_Int32 nLength = xAttrList->getLength(); + for(sal_Int32 nAttr = 0; nAttr < nLength; nAttr++) + { + OUString sLocalName; + sal_uInt16 nPrefix = GetImport().GetNamespaceMap(). + GetKeyByAttrName( xAttrList->getNameByIndex(nAttr), + &sLocalName ); + if ( (XML_NAMESPACE_TEXT == nPrefix) && + (sLocalName.equalsAsciiL(sXML_style_name, + sizeof(sXML_style_name)-1)) ) + { + sCharStyleName = xAttrList->getValueByIndex(nAttr); + bCharStyleNameOK = sal_True; + } + } + + // if we have a style name, set it! + if (bCharStyleNameOK) + { + nValues++; + } + +} + +void XMLIndexSimpleEntryContext::EndElement() +{ + Sequence<PropertyValue> aValues(nValues); + + FillPropertyValues(aValues); + rTemplateContext.addTemplateEntry(aValues); +} + +void XMLIndexSimpleEntryContext::FillPropertyValues( + ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue> & rValues) +{ + // due to the limited number of subclasses, we fill the values + // directly into the slots. Subclasses will have to know they can + // only use slot so-and-so. + + Any aAny; + + // token type + rValues[0].Name = rTemplateContext.sTokenType; + aAny <<= rEntryType; + rValues[0].Value = aAny; + + // char style + if (bCharStyleNameOK) + { + rValues[1].Name = rTemplateContext.sCharacterStyleName; + aAny <<= sCharStyleName; + rValues[1].Value = aAny; + } + +} diff --git a/xmloff/source/text/XMLIndexSimpleEntryContext.hxx b/xmloff/source/text/XMLIndexSimpleEntryContext.hxx new file mode 100644 index 000000000000..e96ce4cd3d06 --- /dev/null +++ b/xmloff/source/text/XMLIndexSimpleEntryContext.hxx @@ -0,0 +1,138 @@ +/************************************************************************* + * + * $RCSfile: XMLIndexSimpleEntryContext.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dvo $ $Date: 2000-11-02 15:51:18 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XMLOFF_XMLINDEXSIMPLEENTRYCONTEXT_HXX_ +#define _XMLOFF_XMLINDEXSIMPLEENTRYCONTEXT_HXX_ + +#ifndef _XMLOFF_XMLICTXT_HXX +#include "xmlictxt.hxx" +#endif + +#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_ +#include <com/sun/star/uno/Reference.h> +#endif + +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_H_ +#include <com/sun/star/uno/Sequence.h> +#endif + +#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ +#include <com/sun/star/beans/PropertyValue.hpp> +#endif + + +namespace com { namespace sun { namespace star { + namespace xml { namespace sax { class XAttributeList; } } +} } } +namespace rtl { class OUString; } +class XMLIndexTemplateContext; + +/** + * Import index entry templates + */ +class XMLIndexSimpleEntryContext : public SvXMLImportContext +{ + + // entry type + const ::rtl::OUString& rEntryType; + + // character style + ::rtl::OUString sCharStyleName; + sal_Bool bCharStyleNameOK; + +protected: + // surrounding template + XMLIndexTemplateContext& rTemplateContext; + + // number of values for PropertyValues + sal_Int32 nValues; + +public: + + TYPEINFO(); + + XMLIndexSimpleEntryContext( + SvXMLImport& rImport, + const ::rtl::OUString& rEntry, + XMLIndexTemplateContext& rTemplate, + sal_uInt16 nPrfx, + const ::rtl::OUString& rLocalName ); + + ~XMLIndexSimpleEntryContext(); + +protected: + + /** process parameters */ + virtual void StartElement( + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList> & xAttrList); + + /** call FillPropertyValues and insert into template */ + virtual void EndElement(); + + /** fill property values for this template entry */ + virtual void FillPropertyValues( + ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue> & rValues); + +}; + +#endif diff --git a/xmloff/source/text/XMLIndexSpanEntryContext.cxx b/xmloff/source/text/XMLIndexSpanEntryContext.cxx new file mode 100644 index 000000000000..4491d7e93aba --- /dev/null +++ b/xmloff/source/text/XMLIndexSpanEntryContext.cxx @@ -0,0 +1,119 @@ +/************************************************************************* + * + * $RCSfile: XMLIndexSpanEntryContext.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dvo $ $Date: 2000-11-02 15:51:18 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XMLOFF_XMLINDEXSPANENTRYCONTEXT_HXX_ +#include "XMLIndexSpanEntryContext.hxx" +#endif + +#ifndef _RTL_USTRING_ +#include <rtl/ustring> +#endif + +#ifndef _XMLOFF_XMLINDEXTEMPLATECONTEXT_HXX_ +#include "XMLIndexTemplateContext.hxx" +#endif + +#ifndef _XMLOFF_XMLICTXT_HXX +#include "xmlictxt.hxx" +#endif + + +using ::rtl::OUString; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::Any; +using ::com::sun::star::beans::PropertyValue; + + +TYPEINIT1( XMLIndexSpanEntryContext, XMLIndexSimpleEntryContext); + +XMLIndexSpanEntryContext::XMLIndexSpanEntryContext( + SvXMLImport& rImport, + XMLIndexTemplateContext& rTemplate, + sal_uInt16 nPrfx, + const OUString& rLocalName ) : + XMLIndexSimpleEntryContext(rImport, rTemplate.sTokenText, + rTemplate, nPrfx, rLocalName) +{ + nValues++; // one more for the text string +} + +XMLIndexSpanEntryContext::~XMLIndexSpanEntryContext() +{ +} + +void XMLIndexSpanEntryContext::Characters(const OUString& sString) +{ + sContent.append(sString); +} + +void XMLIndexSpanEntryContext::FillPropertyValues( + Sequence<PropertyValue> & rValues) +{ + // call superclass for token type, stylename, + XMLIndexSimpleEntryContext::FillPropertyValues(rValues); + + // content + Any aAny; + aAny <<= sContent.makeStringAndClear(); + rValues[nValues-1].Name = rTemplateContext.sText; + rValues[nValues-1].Value = aAny; +} + diff --git a/xmloff/source/text/XMLIndexSpanEntryContext.hxx b/xmloff/source/text/XMLIndexSpanEntryContext.hxx new file mode 100644 index 000000000000..1debecfc2c8a --- /dev/null +++ b/xmloff/source/text/XMLIndexSpanEntryContext.hxx @@ -0,0 +1,120 @@ +/************************************************************************* + * + * $RCSfile: XMLIndexSpanEntryContext.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dvo $ $Date: 2000-11-02 15:51:18 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XMLOFF_XMLINDEXSPANENTRYCONTEXT_HXX_ +#define _XMLOFF_XMLINDEXSPANENTRYCONTEXT_HXX_ + +#ifndef _XMLOFF_XMLINDEXSIMPLEENTRYCONTEXT_HXX_ +#include "XMLIndexSimpleEntryContext.hxx" +#endif + +#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_ +#include <com/sun/star/uno/Reference.h> +#endif + +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_H_ +#include <com/sun/star/uno/Sequence.h> +#endif + +#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ +#include <com/sun/star/beans/PropertyValue.hpp> +#endif + +#ifndef _RTL_USTRBUF_HXX_ +#include <rtl/ustrbuf.hxx> +#endif + +namespace com { namespace sun { namespace star { + namespace xml { namespace sax { class XAttributeList; } } +} } } +namespace rtl { class OUString; } + +/** + * Import index entry templates + */ +class XMLIndexSpanEntryContext : public XMLIndexSimpleEntryContext +{ + ::rtl::OUStringBuffer sContent; + +public: + + TYPEINFO(); + + XMLIndexSpanEntryContext( + SvXMLImport& rImport, + XMLIndexTemplateContext& rTemplate, + sal_uInt16 nPrfx, + const ::rtl::OUString& rLocalName ); + + ~XMLIndexSpanEntryContext(); + +protected: + + /// Collect element contents + virtual void Characters(const ::rtl::OUString& sString); + + /// add Text PropertyValue + virtual void FillPropertyValues( + ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue> & rValues); +}; + +#endif diff --git a/xmloff/source/text/XMLIndexTOCContext.cxx b/xmloff/source/text/XMLIndexTOCContext.cxx new file mode 100644 index 000000000000..95657bb43223 --- /dev/null +++ b/xmloff/source/text/XMLIndexTOCContext.cxx @@ -0,0 +1,225 @@ +/************************************************************************* + * + * $RCSfile: XMLIndexTOCContext.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dvo $ $Date: 2000-11-02 15:51:18 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +#ifndef _XMLOFF_XMLINDEXTOCCONTEXT_HXX_ +#include "XMLIndexTOCContext.hxx" +#endif + +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#endif + +#ifndef _COM_SUN_STAR_UNO_XINTERFACE_HPP_ +#include <com/sun/star/uno/XInterface.hpp> +#endif + +#ifndef _COM_SUN_STAR_TEXT_XTEXTCONTENT_HPP_ +#include <com/sun/star/text/XTextContent.hpp> +#endif + +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif + +#ifndef _XMLOFF_XMLINDEXTOCSOURCECONTEXT_HXX_ +#include "XMLIndexTOCSourceContext.hxx" +#endif + +#ifndef _XMLOFF_XMLICTXT_HXX +#include "xmlictxt.hxx" +#endif + +#ifndef _XMLOFF_XMLIMP_HXX +#include "xmlimp.hxx" +#endif + +#ifndef _XMLOFF_TEXTIMP_HXX_ +#include "txtimp.hxx" +#endif + +#ifndef _XMLOFF_NMSPMAP_HXX +#include "nmspmap.hxx" +#endif + +#ifndef _XMLOFF_XMLNMSPE_HXX +#include "xmlnmspe.hxx" +#endif + +#ifndef _XMLOFF_XMLKYWD_HXX +#include "xmlkywd.hxx" +#endif + +#ifndef _XMLOFF_PRSTYLEI_HXX_ +#include "prstylei.hxx" +#endif + +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif + +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::text; + +using ::rtl::OUString; +using ::com::sun::star::beans::XPropertySet; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::xml::sax::XAttributeList; +using ::com::sun::star::lang::XMultiServiceFactory; + + +TYPEINIT1(XMLIndexTOCContext, SvXMLImportContext); + +XMLIndexTOCContext::XMLIndexTOCContext( + SvXMLImport& rImport, + sal_uInt16 nPrfx, + const OUString& rLocalName ) : + SvXMLImportContext(rImport, nPrfx, rLocalName) +{ +} + +XMLIndexTOCContext::~XMLIndexTOCContext() +{ +} + +void XMLIndexTOCContext::StartElement( + const Reference<XAttributeList> & xAttrList) +{ + // TODO: solve properly when API is up to task + const sal_Char sAPI_toc[] = "com.sun.star.text.ContentIndex"; + const OUString sContentIndex(RTL_CONSTASCII_USTRINGPARAM(sAPI_toc)); + + // create table of content (via MultiServiceFactory) + Reference<XMultiServiceFactory> xFactory(GetImport().GetModel(),UNO_QUERY); + if( xFactory.is() ) + { + Reference<XInterface> xIfc = xFactory->createInstance(sContentIndex); + if( xIfc.is() ) + { + Reference<XTextContent> xTextContent(xIfc, UNO_QUERY); + GetImport().GetTextImport()->InsertTextContent(xTextContent); + + Reference<XPropertySet> xPropSet(xIfc, UNO_QUERY); + xTOCPropertySet = xPropSet; + } + } + + // find text:style-name attribute and set section style + sal_Int32 nCount = xAttrList->getLength(); + for(sal_Int32 nAttr = 0; nAttr < nCount; nAttr++) + { + OUString sLocalName; + sal_uInt16 nPrefix = GetImport().GetNamespaceMap(). + GetKeyByAttrName( xAttrList->getNameByIndex(nAttr), + &sLocalName ); + if ( (XML_NAMESPACE_TEXT == nPrefix) && + (sLocalName.equalsAsciiL(sXML_style_name, + sizeof(sXML_style_name)-1)) ) + { + XMLPropStyleContext* pStyle = + GetImport().GetTextImport()->FindSectionStyle( + xAttrList->getValueByIndex(nAttr)); + if (pStyle != NULL) + { + pStyle->FillPropertySet( xTOCPropertySet ); + } + } + } +} + +void XMLIndexTOCContext::EndElement() +{ + // nothing left +} + +SvXMLImportContext* XMLIndexTOCContext::CreateChildContext( + sal_uInt16 nPrefix, + const OUString& rLocalName, + const Reference<XAttributeList> & xAttrList ) +{ + SvXMLImportContext* pContext = NULL; + + if ( (XML_NAMESPACE_TEXT == nPrefix) && + (rLocalName.equalsAsciiL(sXML_table_of_content_source, + sizeof(sXML_table_of_content_source)-1)) ) + { + pContext = new XMLIndexTOCSourceContext(GetImport(), + nPrefix, rLocalName, + xTOCPropertySet); + } + else + { + // TODO: text content + } + + // default: ignore + if (pContext == NULL) + { + pContext = SvXMLImportContext::CreateChildContext(nPrefix, rLocalName, + xAttrList); + } + + return pContext; +} diff --git a/xmloff/source/text/XMLIndexTOCContext.hxx b/xmloff/source/text/XMLIndexTOCContext.hxx new file mode 100644 index 000000000000..e91c783fd326 --- /dev/null +++ b/xmloff/source/text/XMLIndexTOCContext.hxx @@ -0,0 +1,117 @@ +/************************************************************************* + * + * $RCSfile: XMLIndexTOCContext.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dvo $ $Date: 2000-11-02 15:51:18 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XMLOFF_XMLINDEXTOCCONTEXT_HXX_ +#define _XMLOFF_XMLINDEXTOCCONTEXT_HXX_ + +#ifndef _XMLOFF_XMLICTXT_HXX +#include "xmlictxt.hxx" +#endif + +#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_ +#include <com/sun/star/uno/Reference.h> +#endif + + +namespace com { namespace sun { namespace star { + namespace xml { namespace sax { class XAttributeList; } } + namespace beans { class XPropertySet; } +} } } +namespace rtl { class OUString; } + + +/** + * Import table of context + */ +class XMLIndexTOCContext : public SvXMLImportContext +{ + + /** XPropertySet of the index */ + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet> xTOCPropertySet; + +public: + + TYPEINFO(); + + XMLIndexTOCContext( + SvXMLImport& rImport, + sal_uInt16 nPrfx, + const ::rtl::OUString& rLocalName ); + + ~XMLIndexTOCContext(); + +protected: + + virtual void StartElement( + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList> & xAttrList); + + virtual void EndElement(); + + virtual SvXMLImportContext *CreateChildContext( + sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList> & xAttrList ); +}; + +#endif diff --git a/xmloff/source/text/XMLIndexTOCSourceContext.cxx b/xmloff/source/text/XMLIndexTOCSourceContext.cxx new file mode 100644 index 000000000000..b3aeaf78fb58 --- /dev/null +++ b/xmloff/source/text/XMLIndexTOCSourceContext.cxx @@ -0,0 +1,315 @@ +/************************************************************************* + * + * $RCSfile: XMLIndexTOCSourceContext.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dvo $ $Date: 2000-11-02 15:51:18 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +#ifndef _XMLOFF_XMLINDEXTOCSOURCECONTEXT_HXX_ +#include "XMLIndexTOCSourceContext.hxx" +#endif + +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif + +#ifndef _COM_SUN_STAR_CONTAINER_XINDEXREPLACE_HPP_ +#include <com/sun/star/container/XIndexReplace.hpp> +#endif + +#ifndef _XMLOFF_XMLINDEXTEMPLATECONTEXT_HXX_ +#include "XMLIndexTemplateContext.hxx" +#endif + +#ifndef _XMLOFF_XMLINDEXTITLETEMPLATECONTEXT_HXX_ +#include "XMLIndexTitleTemplateContext.hxx" +#endif + +#ifndef _XMLOFF_XMLINDEXTOCSTYLESCONTEXT_HXX_ +#include "XMLIndexTOCStylesContext.hxx" +#endif + +#ifndef _XMLOFF_XMLICTXT_HXX +#include "xmlictxt.hxx" +#endif + +#ifndef _XMLOFF_XMLIMP_HXX +#include "xmlimp.hxx" +#endif + +#ifndef _XMLOFF_TEXTIMP_HXX_ +#include "txtimp.hxx" +#endif + +#ifndef _XMLOFF_XMLNMSPE_HXX +#include "xmlnmspe.hxx" +#endif + +#ifndef _XMLOFF_NMSPMAP_HXX +#include "nmspmap.hxx" +#endif + +#ifndef _XMLOFF_XMLKYWD_HXX +#include "xmlkywd.hxx" +#endif + +#ifndef _XMLOFF_XMLUCONV_HXX +#include "xmluconv.hxx" +#endif + +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif + +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif + + + + +using ::rtl::OUString; +using ::com::sun::star::beans::XPropertySet; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Any; +using ::com::sun::star::xml::sax::XAttributeList; + +const sal_Char sAPI_CreateFromChapter[] = "CreateFromChapter"; +const sal_Char sAPI_CreateFromOutline[] = "CreateFromOutline"; +const sal_Char sAPI_CreateFromMarks[] = "CreateFromMarks"; +const sal_Char sAPI_Level[] = "Level"; + +TYPEINIT1( XMLIndexTOCSourceContext, SvXMLImportContext ); + +XMLIndexTOCSourceContext::XMLIndexTOCSourceContext( + SvXMLImport& rImport, + sal_uInt16 nPrfx, + const OUString& rLocalName, + Reference<XPropertySet> & rPropSet) : + SvXMLImportContext(rImport, nPrfx, rLocalName), + rTOCPropertySet(rPropSet), + // use all chapters by default + nOutlineLevel(rImport.GetTextImport()->GetChapterNumbering()-> + getCount()), + bUseOutline(sal_True), + bUseMarks(sal_True), + bChapterIndex(sal_False), + bRelativeTabs(sal_True), + sCreateFromMarks(RTL_CONSTASCII_USTRINGPARAM(sAPI_CreateFromMarks)), + sLevel(RTL_CONSTASCII_USTRINGPARAM(sAPI_Level)), + sCreateFromChapter(RTL_CONSTASCII_USTRINGPARAM(sAPI_CreateFromChapter)), + sCreateFromOutline(RTL_CONSTASCII_USTRINGPARAM(sAPI_CreateFromOutline)) +{ +} + +XMLIndexTOCSourceContext::~XMLIndexTOCSourceContext() +{ +} + +enum IndexTOCSourceTokenEnum +{ + XML_TOK_TOCSOURCE_OUTLINE_LEVEL, + XML_TOK_TOCSOURCE_USE_INDEX_MARKS, + XML_TOK_TOCSOURCE_INDEX_SCOPE, + XML_TOK_TOCSOURCE_RELATIVE_TABS +}; + +static __FAR_DATA SvXMLTokenMapEntry aIndexTOCSourceTokenMap[] = +{ + { XML_NAMESPACE_TEXT, sXML_outline_level, XML_TOK_TOCSOURCE_OUTLINE_LEVEL}, + { XML_NAMESPACE_TEXT, sXML_use_index_marks, + XML_TOK_TOCSOURCE_USE_INDEX_MARKS }, + { XML_NAMESPACE_TEXT, sXML_index_scope, XML_TOK_TOCSOURCE_INDEX_SCOPE }, + { XML_NAMESPACE_TEXT, sXML_relative_tab_stop_position, + XML_TOK_TOCSOURCE_RELATIVE_TABS } , + XML_TOKEN_MAP_END +}; + +void XMLIndexTOCSourceContext::StartElement( + const Reference<XAttributeList> & xAttrList) +{ + SvXMLTokenMap aTokenMap(aIndexTOCSourceTokenMap); + + // process attributes + sal_Int32 nLength = xAttrList->getLength(); + for(sal_Int32 i=0; i<nLength; i++) + { + + OUString sLocalName; + sal_uInt16 nPrefix = GetImport().GetNamespaceMap(). + GetKeyByAttrName( xAttrList->getNameByIndex(i), &sLocalName ); + + OUString sAttr = xAttrList->getValueByIndex(i); + + switch (aTokenMap.Get(nPrefix, sLocalName)) + { + case XML_TOK_TOCSOURCE_OUTLINE_LEVEL: + if (sAttr.equalsAsciiL(sXML_none, sizeof(sXML_none)-1)) + { + bUseOutline = sal_False; + } + else + { + sal_Int32 nTmp; + if (SvXMLUnitConverter::convertNumber( + nTmp, sAttr, 1, GetImport().GetTextImport()-> + GetChapterNumbering()->getCount())) + { + bUseOutline = sal_True; + nOutlineLevel = nTmp; + } + } + break; + + case XML_TOK_TOCSOURCE_USE_INDEX_MARKS: + { + sal_Bool bTmp; + if (SvXMLUnitConverter::convertBool(bTmp, sAttr)) + { + bUseMarks = bTmp; + } + break; + } + + case XML_TOK_TOCSOURCE_INDEX_SCOPE: + if (sAttr.equalsAsciiL(sXML_chapter, sizeof(sXML_chapter)-1)) + { + bChapterIndex = sal_True; + } + break; + + case XML_TOK_TOCSOURCE_RELATIVE_TABS: + { + sal_Bool bTmp; + if (SvXMLUnitConverter::convertBool(bTmp, sAttr)) + { + bRelativeTabs = bTmp; + } + break; + } + + default: + // unknown attribute -> ignore + break; + } + } +} + +void XMLIndexTOCSourceContext::EndElement() +{ + Any aAny; + + aAny.setValue(&bRelativeTabs, ::getBooleanCppuType()); +// rTOCPropertySet->setPropertyValue(s..., aAny); + + aAny.setValue(&bChapterIndex, ::getBooleanCppuType()); + rTOCPropertySet->setPropertyValue(sCreateFromChapter, aAny); + + aAny.setValue(&bUseMarks, ::getBooleanCppuType()); + rTOCPropertySet->setPropertyValue(sCreateFromMarks, aAny); + + aAny.setValue(&bUseOutline, ::getBooleanCppuType()); + rTOCPropertySet->setPropertyValue(sCreateFromOutline, aAny); + + aAny <<= (sal_Int16)nOutlineLevel; + rTOCPropertySet->setPropertyValue(sLevel, aAny); +} + +SvXMLImportContext* XMLIndexTOCSourceContext::CreateChildContext( + sal_uInt16 nPrefix, + const OUString& rLocalName, + const Reference<XAttributeList> & xAttrList ) +{ + SvXMLImportContext* pContext = NULL; + + if (XML_NAMESPACE_TEXT == nPrefix) + { + if (rLocalName.equalsAsciiL(sXML_index_entry_template, + sizeof(sXML_index_entry_template)-1)) + { + pContext = new XMLIndexTemplateContext(GetImport(), + rTOCPropertySet, + nPrefix, rLocalName); + } + else if (rLocalName.equalsAsciiL(sXML_index_title_template, + sizeof(sXML_index_title_template)-1)) + { + pContext = new XMLIndexTitleTemplateContext(GetImport(), + rTOCPropertySet, + nPrefix, rLocalName); + } + else if (rLocalName.equalsAsciiL(sXML_index_source_styles, + sizeof(sXML_index_source_styles)-1)) + { + pContext = new XMLIndexTOCStylesContext(GetImport(), + rTOCPropertySet, + nPrefix, rLocalName); + } + // else: unknown element in text namespace -> ignore + } + // else: unknown namespace -> ignore + + // use default namespace + if (pContext == NULL) + { + pContext = SvXMLImportContext::CreateChildContext(nPrefix, rLocalName, + xAttrList); + } + + return pContext; +} diff --git a/xmloff/source/text/XMLIndexTOCSourceContext.hxx b/xmloff/source/text/XMLIndexTOCSourceContext.hxx new file mode 100644 index 000000000000..3e1db09ef1df --- /dev/null +++ b/xmloff/source/text/XMLIndexTOCSourceContext.hxx @@ -0,0 +1,128 @@ +/************************************************************************* + * + * $RCSfile: XMLIndexTOCSourceContext.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dvo $ $Date: 2000-11-02 15:51:18 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XMLOFF_XMLINDEXTOCSOURCECONTEXT_HXX_ +#define _XMLOFF_XMLINDEXTOCSOURCECONTEXT_HXX_ + +#ifndef _XMLOFF_XMLICTXT_HXX +#include "xmlictxt.hxx" +#endif + +#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_ +#include <com/sun/star/uno/Reference.h> +#endif + + +namespace com { namespace sun { namespace star { + namespace xml { namespace sax { class XAttributeList; } } + namespace beans { class XPropertySet; } +} } } +namespace rtl { class OUString; } + + +/** + * Import table of context source element + */ +class XMLIndexTOCSourceContext : public SvXMLImportContext +{ + const ::rtl::OUString sCreateFromMarks; + const ::rtl::OUString sLevel; + const ::rtl::OUString sCreateFromChapter; + const ::rtl::OUString sCreateFromOutline; + + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet> & rTOCPropertySet; + + sal_Int32 nOutlineLevel; + sal_Bool bUseOutline; + sal_Bool bUseMarks; + sal_Bool bChapterIndex; + sal_Bool bRelativeTabs; + +public: + + TYPEINFO(); + + XMLIndexTOCSourceContext( + SvXMLImport& rImport, + sal_uInt16 nPrfx, + const ::rtl::OUString& rLocalName, + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet> & rPropSet); + + ~XMLIndexTOCSourceContext(); + +protected: + + virtual void StartElement( + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList> & xAttrList); + + virtual void EndElement(); + + virtual SvXMLImportContext* CreateChildContext( + sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList> & xAttrList ); +}; + +#endif diff --git a/xmloff/source/text/XMLIndexTOCStylesContext.cxx b/xmloff/source/text/XMLIndexTOCStylesContext.cxx new file mode 100644 index 000000000000..0bba317e20a6 --- /dev/null +++ b/xmloff/source/text/XMLIndexTOCStylesContext.cxx @@ -0,0 +1,229 @@ +/************************************************************************* + * + * $RCSfile: XMLIndexTOCStylesContext.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dvo $ $Date: 2000-11-02 15:51:18 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + + +#ifndef _XMLOFF_XMLINDEXTOCSTYLESCONTEXT_HXX_ +#include "XMLIndexTOCStylesContext.hxx" +#endif + +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif + +#ifndef _COM_SUN_STAR_CONTAINER_XINDEXREPLACE_HPP_ +#include <com/sun/star/container/XIndexReplace.hpp> +#endif + +#ifndef _XMLOFF_XMLICTXT_HXX +#include "xmlictxt.hxx" +#endif + +#ifndef _XMLOFF_XMLIMP_HXX +#include "xmlimp.hxx" +#endif + +#ifndef _XMLOFF_TEXTIMP_HXX_ +#include "txtimp.hxx" +#endif + +#ifndef _XMLOFF_XMLNMSPE_HXX +#include "xmlnmspe.hxx" +#endif + +#ifndef _XMLOFF_NMSPMAP_HXX +#include "nmspmap.hxx" +#endif + +#ifndef _XMLOFF_XMLKYWD_HXX +#include "xmlkywd.hxx" +#endif + +#ifndef _XMLOFF_XMLUCONV_HXX +#include "xmluconv.hxx" +#endif + +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_ +#include <com/sun/star/uno/Sequence.hxx> +#endif + +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif + +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif + +using ::rtl::OUString; +using ::com::sun::star::beans::XPropertySet; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::Any; +using ::com::sun::star::container::XIndexReplace; +using ::com::sun::star::xml::sax::XAttributeList; + +const sal_Char sAPI_LevelParagraphStyles[] = "LevelParagraphStyles"; + +TYPEINIT1( XMLIndexTOCStylesContext, SvXMLImportContext ); + + +XMLIndexTOCStylesContext::XMLIndexTOCStylesContext( + SvXMLImport& rImport, + Reference<XPropertySet> & rPropSet, + sal_uInt16 nPrfx, + const OUString& rLocalName ) : + SvXMLImportContext(rImport, nPrfx, rLocalName), + rTOCPropertySet(rPropSet), + aStyleNames(), + nOutlineLevel(-1), + sLevelParagraphStyles(RTL_CONSTASCII_USTRINGPARAM( + sAPI_LevelParagraphStyles)) +{ +} + +XMLIndexTOCStylesContext::~XMLIndexTOCStylesContext() +{ +} + +void XMLIndexTOCStylesContext::StartElement( + const Reference<XAttributeList> & xAttrList ) +{ + // find text:outline-level attribute + sal_Int32 nCount = xAttrList->getLength(); + for(sal_Int32 nAttr = 0; nAttr < nCount; nAttr++) + { + OUString sLocalName; + sal_uInt16 nPrefix = GetImport().GetNamespaceMap(). + GetKeyByAttrName( xAttrList->getNameByIndex(nAttr), + &sLocalName ); + if ( (XML_NAMESPACE_TEXT == nPrefix) && + (sLocalName.equalsAsciiL(sXML_outline_level, + sizeof(sXML_outline_level)-1)) ) + { + sal_Int32 nTmp; + if (SvXMLUnitConverter::convertNumber( + nTmp, xAttrList->getValueByIndex(nAttr), 1, + GetImport().GetTextImport()->GetChapterNumbering()-> + getCount())) + { + // API numbers 0..9, we number 1..10 + nOutlineLevel = nTmp-1; + } + } + } +} + +void XMLIndexTOCStylesContext::EndElement() +{ + // if valid... + if (nOutlineLevel >= 0) + { + // copy vector into sequence + sal_Int32 nCount = aStyleNames.size(); + Sequence<OUString> aStyleNamesSequence(nCount); + for(sal_Int32 i = 0; i < nCount; i++) + { + aStyleNamesSequence[i] = aStyleNames[i]; + } + + // get index replace + Any aAny = rTOCPropertySet->getPropertyValue(sLevelParagraphStyles); + Reference<XIndexReplace> xIndexReplace; + aAny >>= xIndexReplace; + + // set style names + aAny <<= aStyleNamesSequence; + xIndexReplace->replaceByIndex(nOutlineLevel, aAny); + } +} + +SvXMLImportContext *XMLIndexTOCStylesContext::CreateChildContext( + sal_uInt16 nPrefix, + const OUString& rLocalName, + const Reference<XAttributeList> & xAttrList ) +{ + // check for index-source-style + if ( (XML_NAMESPACE_TEXT == nPrefix) && + rLocalName.equalsAsciiL(sXML_index_source_style, + sizeof(sXML_index_source_style)-1) ) + { + // find text:style-name attribute and record in aStyleNames + sal_Int32 nCount = xAttrList->getLength(); + for(sal_Int32 nAttr = 0; nAttr < nCount; nAttr++) + { + OUString sLocalName; + sal_uInt16 nPrefix = GetImport().GetNamespaceMap(). + GetKeyByAttrName( xAttrList->getNameByIndex(nAttr), + &sLocalName ); + if ( (XML_NAMESPACE_TEXT == nPrefix) && + (sLocalName.equalsAsciiL(sXML_style_name, + sizeof(sXML_style_name)-1)) ) + { + aStyleNames.push_back(xAttrList->getValueByIndex(nAttr)); + } + } + } + + // always return default context; we already got the interesting info + return SvXMLImportContext::CreateChildContext(nPrefix, rLocalName, + xAttrList); +} diff --git a/xmloff/source/text/XMLIndexTOCStylesContext.hxx b/xmloff/source/text/XMLIndexTOCStylesContext.hxx new file mode 100644 index 000000000000..d9af661bc888 --- /dev/null +++ b/xmloff/source/text/XMLIndexTOCStylesContext.hxx @@ -0,0 +1,136 @@ +/************************************************************************* + * + * $RCSfile: XMLIndexTOCStylesContext.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dvo $ $Date: 2000-11-02 15:51:18 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XMLOFF_XMLINDEXTOCSTYLESCONTEXT_HXX_ +#define _XMLOFF_XMLINDEXTOCSTYLESCONTEXT_HXX_ + +#ifndef _XMLOFF_XMLICTXT_HXX +#include "xmlictxt.hxx" +#endif + +#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_ +#include <com/sun/star/uno/Reference.h> +#endif + +#ifndef __SGI_STL_VECTOR +#include <stl/vector> +#endif + + +namespace com { namespace sun { namespace star { + namespace xml { namespace sax { class XAttributeList; } } + namespace beans { class XPropertySet; } +} } } +namespace rtl { class OUString; } + + +/** + * Import <test:index-source-styles> elements and their children + * + * (Small hackery here: Because there's only one type of child + * elements with only one interesting attribute, we completely handle + * them inside the CreateChildContext method, rather than creating a + * new import class for them. This must be changed if children become + * more complex in future versions.) + */ +class XMLIndexTOCStylesContext : public SvXMLImportContext +{ + const ::rtl::OUString sLevelParagraphStyles; + + /// XPropertySet of the index + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet> & rTOCPropertySet; + + /// style names for this level + ::std::vector<::rtl::OUString> aStyleNames; + + /// outline level + sal_Int32 nOutlineLevel; + +public: + + TYPEINFO(); + + XMLIndexTOCStylesContext( + SvXMLImport& rImport, + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet> & rPropSet, + sal_uInt16 nPrfx, + const ::rtl::OUString& rLocalName ); + + ~XMLIndexTOCStylesContext(); + +protected: + + virtual void StartElement( + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList> & xAttrList); + + virtual void EndElement(); + + virtual SvXMLImportContext *CreateChildContext( + sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList> & xAttrList ); +}; + +#endif diff --git a/xmloff/source/text/XMLIndexTabStopEntryContext.cxx b/xmloff/source/text/XMLIndexTabStopEntryContext.cxx new file mode 100644 index 000000000000..8c141ad53683 --- /dev/null +++ b/xmloff/source/text/XMLIndexTabStopEntryContext.cxx @@ -0,0 +1,218 @@ +/************************************************************************* + * + * $RCSfile: XMLIndexTabStopEntryContext.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dvo $ $Date: 2000-11-02 15:51:18 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +#ifndef _XMLOFF_XMLINDEXTABSTOPENTRYCONTEXT_HXX_ +#include "XMLIndexTabStopEntryContext.hxx" +#endif + +#ifndef _XMLOFF_XMLINDEXTEMPLATECONTEXT_HXX_ +#include "XMLIndexTemplateContext.hxx" +#endif + +#ifndef _XMLOFF_XMLICTXT_HXX +#include "xmlictxt.hxx" +#endif + +#ifndef _XMLOFF_XMLIMP_HXX +#include "xmlimp.hxx" +#endif + +#ifndef _XMLOFF_TEXTIMP_HXX_ +#include "txtimp.hxx" +#endif + +#ifndef _XMLOFF_NMSPMAP_HXX +#include "nmspmap.hxx" +#endif + +#ifndef _XMLOFF_XMLNMSPE_HXX +#include "xmlnmspe.hxx" +#endif + +#ifndef _XMLOFF_XMLKYWD_HXX +#include "xmlkywd.hxx" +#endif + +#ifndef _XMLOFF_XMLUCONV_HXX +#include "xmluconv.hxx" +#endif + +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif + +using ::rtl::OUString; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Any; +using ::com::sun::star::beans::PropertyValue; +using ::com::sun::star::xml::sax::XAttributeList; + +TYPEINIT1( XMLIndexTabStopEntryContext, SvXMLImportContext ); + +XMLIndexTabStopEntryContext::XMLIndexTabStopEntryContext( + SvXMLImport& rImport, + XMLIndexTemplateContext& rTemplate, + sal_uInt16 nPrfx, + const OUString& rLocalName ) : + SvXMLImportContext(rImport, nPrfx, rLocalName), + rTemplateContext(rTemplate), + sLeaderChar(), + nTabPosition(0), + bTabPositionOK(sal_False), + bTabRightAligned(sal_False), + bLeaderCharOK(sal_False) +{ +} + +XMLIndexTabStopEntryContext::~XMLIndexTabStopEntryContext() +{ +} + +void XMLIndexTabStopEntryContext::StartElement( + const Reference<XAttributeList> & xAttrList) +{ + // process three attributes: type, position, leader char + sal_Int32 nLength = xAttrList->getLength(); + for(sal_Int32 nAttr = 0; nAttr < nLength; nAttr++) + { + OUString sLocalName; + sal_uInt16 nPrefix = GetImport().GetNamespaceMap(). + GetKeyByAttrName( xAttrList->getNameByIndex(nAttr), + &sLocalName ); + OUString sAttr = xAttrList->getValueByIndex(nAttr); + if (XML_NAMESPACE_STYLE == nPrefix) + { + if (sLocalName.equalsAsciiL(sXML_type, sizeof(sXML_type)-1)) + { + // if it's neither left nor right, value is + // ignored. Since left is default, we only need to + // check for right + bTabRightAligned = sAttr.equalsAsciiL(sXML_right, + sizeof(sXML_right)-1); + } + else if (sLocalName.equalsAsciiL(sXML_position, + sizeof(sXML_position)-1)) + { + sal_Int32 nTmp; + if (GetImport().GetMM100UnitConverter(). + convertMeasure(nTmp, sAttr)) + { + nTabPosition = nTmp; + bTabPositionOK = sal_True; + } + } + else if (sLocalName.equalsAsciiL(sXML_leader_char, + sizeof(sXML_leader_char)-1)) + { + sLeaderChar = sAttr; + // valid only, if we have a char! + bLeaderCharOK = (sAttr.getLength() > 0); + } + // else: unknown style: attribute -> ignore + } + // else: no style attribute -> ignore + } +} + +void XMLIndexTabStopEntryContext::EndElement() +{ + // how many entries? + sal_Int32 nValues = 2 + (bTabPositionOK ? 1 : 0) + (bLeaderCharOK ? 1 : 0); + + Sequence<PropertyValue> aValues(nValues); + Any aAny; + sal_Int32 nCount = 0; + + // type: tab stop + aValues[nCount].Name = rTemplateContext.sTokenType; + aAny <<= rTemplateContext.sTokenTabStop; + aValues[nCount].Value = aAny; + nCount++; + + // right aligned? + aValues[nCount].Name = rTemplateContext.sTabStopRightAligned; + aAny.setValue(&bTabRightAligned, ::getBooleanCppuType()); + aValues[nCount].Value = aAny; + nCount++; + + // position + if (bTabPositionOK) + { + aValues[nCount].Name = rTemplateContext.sTabStopPosition; + aAny <<= nTabPosition; + aValues[nCount].Value = aAny; + nCount++; + } + + // leader char + if (bLeaderCharOK) + { + aValues[nCount].Name = rTemplateContext.sTabStopFillCharacter; + aAny <<= sLeaderChar; + aValues[nCount].Value = aAny; + nCount++; + } + + // add this template entry + rTemplateContext.addTemplateEntry(aValues); +} diff --git a/xmloff/source/text/XMLIndexTabStopEntryContext.hxx b/xmloff/source/text/XMLIndexTabStopEntryContext.hxx new file mode 100644 index 000000000000..b0736c772b31 --- /dev/null +++ b/xmloff/source/text/XMLIndexTabStopEntryContext.hxx @@ -0,0 +1,125 @@ +/************************************************************************* + * + * $RCSfile: XMLIndexTabStopEntryContext.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dvo $ $Date: 2000-11-02 15:51:18 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XMLOFF_XMLINDEXTABSTOPENTRYCONTEXT_HXX_ +#define _XMLOFF_XMLINDEXTABSTOPENTRYCONTEXT_HXX_ + +#ifndef _XMLOFF_XMLICTXT_HXX +#include "xmlictxt.hxx" +#endif + +#ifndef _RTL_USTRING_ +#include <rtl/ustring> +#endif + +#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_ +#include <com/sun/star/uno/Reference.h> +#endif + +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_H_ +#include <com/sun/star/uno/Sequence.h> +#endif + +#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ +#include <com/sun/star/beans/PropertyValue.hpp> +#endif + + +namespace com { namespace sun { namespace star { + namespace xml { namespace sax { class XAttributeList; } } +} } } +class XMLIndexTemplateContext; + +/** + * Import index entry templates + */ +class XMLIndexTabStopEntryContext : public SvXMLImportContext +{ + XMLIndexTemplateContext& rTemplateContext; + + ::rtl::OUString sLeaderChar; /// fill ("leader") character + sal_Int32 nTabPosition; /// tab position + sal_Bool bTabPositionOK; /// is tab right aligned? + sal_Bool bTabRightAligned; /// is nTabPosition valid? + sal_Bool bLeaderCharOK; /// is sLeaderChar valid? + +public: + + TYPEINFO(); + + XMLIndexTabStopEntryContext( + SvXMLImport& rImport, + XMLIndexTemplateContext& rTemplate, + sal_uInt16 nPrfx, + const ::rtl::OUString& rLocalName ); + + ~XMLIndexTabStopEntryContext(); + +protected: + + virtual void StartElement( + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList> & xAttrList); + + virtual void EndElement(); +}; + +#endif diff --git a/xmloff/source/text/XMLIndexTemplateContext.cxx b/xmloff/source/text/XMLIndexTemplateContext.cxx new file mode 100644 index 000000000000..072a1312972a --- /dev/null +++ b/xmloff/source/text/XMLIndexTemplateContext.cxx @@ -0,0 +1,368 @@ +/************************************************************************* + * + * $RCSfile: XMLIndexTemplateContext.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dvo $ $Date: 2000-11-02 15:51:18 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +#ifndef _XMLOFF_XMLINDEXTEMPLATECONTEXT_HXX_ +#include "XMLIndexTemplateContext.hxx" +#endif + +#ifndef _XMLOFF_XMLINDEXSIMPLEENTRYCONTEXT_HXX_ +#include "XMLIndexSimpleEntryContext.hxx" +#endif + +#ifndef _XMLOFF_XMLINDEXSPANENTRYCONTEXT_HXX_ +#include "XMLIndexSpanEntryContext.hxx" +#endif + +#ifndef _XMLOFF_XMLINDEXTABSTOPENTRYCONTEXT_HXX_ +#include "XMLIndexTabStopEntryContext.hxx" +#endif + +#ifndef _XMLOFF_XMLICTXT_HXX +#include "xmlictxt.hxx" +#endif + +#ifndef _XMLOFF_XMLIMP_HXX +#include "xmlimp.hxx" +#endif + +#ifndef _XMLOFF_TEXTIMP_HXX_ +#include "txtimp.hxx" +#endif + +#ifndef _XMLOFF_NMSPMAP_HXX +#include "nmspmap.hxx" +#endif + +#ifndef _XMLOFF_XMLNMSPE_HXX +#include "xmlnmspe.hxx" +#endif + +#ifndef _XMLOFF_XMLKYWD_HXX +#include "xmlkywd.hxx" +#endif + +#ifndef _XMLOFF_XMLUCONV_HXX +#include "xmluconv.hxx" +#endif + +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif + +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif + +#ifndef _RTL_USTRBUF_HXX_ +#include <rtl/ustrbuf.hxx> +#endif + +#ifndef _COM_SUN_STAR_CONTAINER_XINDEXREPLACE_HPP_ +#include <com/sun/star/container/XIndexReplace.hpp> +#endif + + +using namespace ::std; +//using namespace ::com::sun::star::text; + +using ::rtl::OUString; +using ::rtl::OUStringBuffer; +using ::com::sun::star::beans::XPropertySet; +using ::com::sun::star::beans::PropertyValue; +using ::com::sun::star::beans::PropertyValues; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::Any; +using ::com::sun::star::xml::sax::XAttributeList; +using ::com::sun::star::container::XIndexReplace; + +const sal_Char sAPI_TokenEntryNumber[] = "TokenEntryNumber"; +const sal_Char sAPI_TokenEntryText[] = "TokenEntryText"; +const sal_Char sAPI_TokenTabStop[] = "TokenTabStop"; +const sal_Char sAPI_TokenText[] = "TokenText"; +const sal_Char sAPI_TokenPageNumber[] = "TokenPageNumber"; +const sal_Char sAPI_TokenChapterInfo[] = "TokenChapterInfo"; +const sal_Char sAPI_TokenHyperlinkStart[] = "TokenHyperlinkStart"; +const sal_Char sAPI_TokenHyperlinkEnd[] = "TokenHyperlinkEnd"; +const sal_Char sAPI_TokenBibliographyDataField[] = + "TokenBibliographyDataField"; + + +TYPEINIT1( XMLIndexTemplateContext, SvXMLImportContext); + +XMLIndexTemplateContext::XMLIndexTemplateContext( + SvXMLImport& rImport, + Reference<XPropertySet> & rPropSet, + sal_uInt16 nPrfx, + const OUString& rLocalName ) : + SvXMLImportContext(rImport, nPrfx, rLocalName), + rPropertySet(rPropSet), + sTokenEntryNumber(RTL_CONSTASCII_USTRINGPARAM(sAPI_TokenEntryNumber)), + sTokenEntryText(RTL_CONSTASCII_USTRINGPARAM(sAPI_TokenEntryText)), + sTokenTabStop(RTL_CONSTASCII_USTRINGPARAM(sAPI_TokenTabStop)), + sTokenText(RTL_CONSTASCII_USTRINGPARAM(sAPI_TokenText)), + sTokenPageNumber(RTL_CONSTASCII_USTRINGPARAM(sAPI_TokenPageNumber)), + sTokenChapterInfo(RTL_CONSTASCII_USTRINGPARAM(sAPI_TokenChapterInfo)), + sTokenHyperlinkStart(RTL_CONSTASCII_USTRINGPARAM( + sAPI_TokenHyperlinkStart)), + sTokenHyperlinkEnd(RTL_CONSTASCII_USTRINGPARAM( + sAPI_TokenHyperlinkEnd)), + sTokenBibliographyDataField(RTL_CONSTASCII_USTRINGPARAM( + sAPI_TokenBibliographyDataField)), + sLevelFormat(RTL_CONSTASCII_USTRINGPARAM("LevelFormat")), + sParaStyleLevel(RTL_CONSTASCII_USTRINGPARAM("ParaStyleLevel")), + sTabStopRightAligned(RTL_CONSTASCII_USTRINGPARAM( + "TabStopRightAligned")), + sTabStopPosition(RTL_CONSTASCII_USTRINGPARAM("TabStopPosition")), + sTabStopFillCharacter(RTL_CONSTASCII_USTRINGPARAM( + "TabStopFillCharacter")), + sCharacterStyleName(RTL_CONSTASCII_USTRINGPARAM("CharacterStyleName")), + sTokenType(RTL_CONSTASCII_USTRINGPARAM("TokenType")), + sText(RTL_CONSTASCII_USTRINGPARAM("Text")) +{ +} + +XMLIndexTemplateContext::~XMLIndexTemplateContext() +{ +} + + +void XMLIndexTemplateContext::addTemplateEntry( + const PropertyValues& aValues) +{ + aValueVector.push_back(aValues); +} + +void XMLIndexTemplateContext::StartElement( + const Reference<XAttributeList> & xAttrList) +{ + // process two attributes: style-name, outline-level + sal_Int32 nLength = xAttrList->getLength(); + for(sal_Int32 nAttr = 0; nAttr < nLength; nAttr++) + { + OUString sLocalName; + sal_uInt16 nPrefix = GetImport().GetNamespaceMap(). + GetKeyByAttrName( xAttrList->getNameByIndex(nAttr), + &sLocalName ); + if (XML_NAMESPACE_TEXT == nPrefix) + { + if (sLocalName.equalsAsciiL(sXML_style_name, + sizeof(sXML_style_name)-1)) + { + // style name + sStyleName = xAttrList->getValueByIndex(nAttr); + bStyleNameOK = sal_True; + } + else if (sLocalName.equalsAsciiL(sXML_outline_level, + sizeof(sXML_outline_level)-1)) + { + // outline level + sal_Int32 nTmp; + if (SvXMLUnitConverter::convertNumber( + nTmp, xAttrList->getValueByIndex(nAttr), 1, + GetImport().GetTextImport()-> + GetChapterNumbering()->getCount() )) + { + nOutlineLevel = nTmp; + bOutlineLevelOK = sal_True; + } + } + // else: unknown attribute + } + // else: attribute not in text namespace + } +} + +void XMLIndexTemplateContext::EndElement() +{ + if (bOutlineLevelOK) + { + sal_Int32 nCount = aValueVector.size(); + Sequence<PropertyValues> aValueSequence(nCount); + for(sal_Int32 i = 0; i<nCount; i++) + { + aValueSequence[i] = aValueVector[i]; + } + + // get LevelFormat IndexReplace ... + Any aAny = rPropertySet->getPropertyValue(sLevelFormat); + Reference<XIndexReplace> xIndexReplace; + aAny >>= xIndexReplace; + + // ... and insert + aAny <<= aValueSequence; + xIndexReplace->replaceByIndex(nOutlineLevel, aAny); + + if (bStyleNameOK) + { + // create property name and set + OUStringBuffer sBuf; + sBuf.append(sParaStyleLevel); + sBuf.append(nOutlineLevel); + + aAny <<= sStyleName; + rPropertySet->setPropertyValue(sBuf.makeStringAndClear(), aAny); + } + } +} + +enum TemplateTokenType +{ + XML_TOK_INDEX_TYPE_ENTRY_TEXT, + XML_TOK_INDEX_TYPE_TAB_STOP, + XML_TOK_INDEX_TYPE_TEXT, + XML_TOK_INDEX_TYPE_PAGE_NUMBER, + XML_TOK_INDEX_TYPE_CHAPTER, + XML_TOK_INDEX_TYPE_LINK_START, + XML_TOK_INDEX_TYPE_LINK_END, + XML_TOK_INDEX_TYPE_BIBLIOGRAPHY +}; + +SvXMLEnumMapEntry aTemplateTokenTypeMap[] = +{ + { sXML_index_entry_chapter, XML_TOK_INDEX_TYPE_CHAPTER }, + { sXML_index_entry_text, XML_TOK_INDEX_TYPE_ENTRY_TEXT }, + { sXML_index_entry_tab_stop, XML_TOK_INDEX_TYPE_TAB_STOP }, + { sXML_index_entry_span, XML_TOK_INDEX_TYPE_TEXT }, + { sXML_index_entry_page_number, XML_TOK_INDEX_TYPE_PAGE_NUMBER }, + { sXML_index_entry_chapter, XML_TOK_INDEX_TYPE_CHAPTER }, + { sXML_index_entry_link_start, XML_TOK_INDEX_TYPE_LINK_START }, + { sXML_index_entry_link_end, XML_TOK_INDEX_TYPE_LINK_END }, + { sXML_index_entry_bibliography, XML_TOK_INDEX_TYPE_BIBLIOGRAPHY }, + { 0, 0 } +}; + +SvXMLImportContext *XMLIndexTemplateContext::CreateChildContext( + sal_uInt16 nPrefix, + const OUString& rLocalName, + const Reference<XAttributeList> & xAttrList ) +{ + SvXMLImportContext* pContext = NULL; + + if (XML_NAMESPACE_TEXT == nPrefix) + { + sal_uInt16 nToken; + if (SvXMLUnitConverter::convertEnum(nToken, rLocalName, + aTemplateTokenTypeMap)) + { + switch ((TemplateTokenType)nToken) + { +// TODO: only allow entries for the appropriate index types! + case XML_TOK_INDEX_TYPE_ENTRY_TEXT: + pContext = new XMLIndexSimpleEntryContext( + GetImport(), sTokenEntryText, *this, + nPrefix, rLocalName); + break; + + case XML_TOK_INDEX_TYPE_PAGE_NUMBER: + pContext = new XMLIndexSimpleEntryContext( + GetImport(), sTokenPageNumber, *this, + nPrefix, rLocalName); + break; + + case XML_TOK_INDEX_TYPE_LINK_START: + pContext = new XMLIndexSimpleEntryContext( + GetImport(), sTokenHyperlinkStart, *this, + nPrefix, rLocalName); + break; + + case XML_TOK_INDEX_TYPE_LINK_END: + pContext = new XMLIndexSimpleEntryContext( + GetImport(), sTokenHyperlinkEnd, *this, + nPrefix, rLocalName); + break; + + case XML_TOK_INDEX_TYPE_TEXT: + pContext = new XMLIndexSpanEntryContext( + GetImport(), *this, nPrefix, rLocalName); + break; + + case XML_TOK_INDEX_TYPE_TAB_STOP: + pContext = new XMLIndexTabStopEntryContext( + GetImport(), *this, nPrefix, rLocalName); + break; + + case XML_TOK_INDEX_TYPE_CHAPTER: + // TODO: implement "real" chapter context that + // parses chapter attributes + pContext = new XMLIndexSimpleEntryContext( + GetImport(), sTokenEntryNumber, *this, + nPrefix, rLocalName); + break; + + case XML_TOK_INDEX_TYPE_BIBLIOGRAPHY: + // TODO: bibliography context + default: + break; + } + } + } + + // ignore unknown + if (NULL == pContext) + { + return SvXMLImportContext::CreateChildContext(nPrefix, rLocalName, + xAttrList); + } + + return pContext; +} diff --git a/xmloff/source/text/XMLIndexTemplateContext.hxx b/xmloff/source/text/XMLIndexTemplateContext.hxx new file mode 100644 index 000000000000..c1ebea269291 --- /dev/null +++ b/xmloff/source/text/XMLIndexTemplateContext.hxx @@ -0,0 +1,165 @@ +/************************************************************************* + * + * $RCSfile: XMLIndexTemplateContext.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dvo $ $Date: 2000-11-02 15:51:18 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XMLOFF_XMLINDEXTEMPLATECONTEXT_HXX_ +#define _XMLOFF_XMLINDEXTEMPLATECONTEXT_HXX_ + +#ifndef _XMLOFF_XMLICTXT_HXX +#include "xmlictxt.hxx" +#endif + +#ifndef __SGI_STL_VECTOR +#include <stl/vector> +#endif + +#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_ +#include <com/sun/star/uno/Reference.h> +#endif + +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_H_ +#include <com/sun/star/uno/Sequence.h> +#endif + +#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUES_HPP_ +#include <com/sun/star/beans/PropertyValues.hpp> +#endif + + +namespace com { namespace sun { namespace star { + namespace xml { namespace sax { class XAttributeList; } } + namespace beans { class XPropertySet; } +} } } +namespace rtl { class OUString; } + + +/** + * Import index entry templates + */ +class XMLIndexTemplateContext : public SvXMLImportContext +{ + // pick up PropertyValues to be turned into a sequence. + ::std::vector< ::com::sun::star::beans::PropertyValues > aValueVector; + + ::rtl::OUString sStyleName; + sal_Int32 nOutlineLevel; + sal_Bool bStyleNameOK; + sal_Bool bOutlineLevelOK; + + // PropertySet of current index + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet> & rPropertySet; + +public: + + // constants made available to other contexts (template entry + // contexts, in particular) + const ::rtl::OUString sTokenEntryNumber; + const ::rtl::OUString sTokenEntryText; + const ::rtl::OUString sTokenTabStop; + const ::rtl::OUString sTokenText; + const ::rtl::OUString sTokenPageNumber; + const ::rtl::OUString sTokenChapterInfo; + const ::rtl::OUString sTokenHyperlinkStart; + const ::rtl::OUString sTokenHyperlinkEnd; + const ::rtl::OUString sTokenBibliographyDataField; + + const ::rtl::OUString sCharacterStyleName; + const ::rtl::OUString sTokenType; + const ::rtl::OUString sText; + const ::rtl::OUString sTabStopRightAligned; + const ::rtl::OUString sTabStopPosition; + const ::rtl::OUString sTabStopFillCharacter; + + const ::rtl::OUString sLevelFormat; + const ::rtl::OUString sParaStyleLevel; + + + TYPEINFO(); + + XMLIndexTemplateContext( + SvXMLImport& rImport, + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet> & rPropSet, + sal_uInt16 nPrfx, + const ::rtl::OUString& rLocalName ); + + ~XMLIndexTemplateContext(); + + /** add template; to be called by child template entry contexts */ + void addTemplateEntry( + const ::com::sun::star::beans::PropertyValues& aValues); + +protected: + + virtual void StartElement( + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList> & xAttrList); + + virtual void EndElement(); + + virtual SvXMLImportContext *CreateChildContext( + sal_uInt16 nPrefix, + const ::rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList> & xAttrList ); +}; + +#endif diff --git a/xmloff/source/text/XMLIndexTitleTemplateContext.cxx b/xmloff/source/text/XMLIndexTitleTemplateContext.cxx new file mode 100644 index 000000000000..31696cd64a97 --- /dev/null +++ b/xmloff/source/text/XMLIndexTitleTemplateContext.cxx @@ -0,0 +1,160 @@ +/************************************************************************* + * + * $RCSfile: XMLIndexTitleTemplateContext.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dvo $ $Date: 2000-11-02 15:51:18 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XMLOFF_XMLINDEXTITLETEMPLATECONTEXT_HXX_ +#include "XMLIndexTitleTemplateContext.hxx" +#endif + +#ifndef _XMLOFF_XMLICTXT_HXX +#include "xmlictxt.hxx" +#endif + +#ifndef _XMLOFF_XMLIMP_HXX +#include "xmlimp.hxx" +#endif + +#ifndef _XMLOFF_NMSPMAP_HXX +#include "nmspmap.hxx" +#endif + +#ifndef _XMLOFF_XMLNMSPE_HXX +#include "xmlnmspe.hxx" +#endif + +#ifndef _XMLOFF_XMLKYWD_HXX +#include "xmlkywd.hxx" +#endif + + +using ::rtl::OUString; +using ::rtl::OUStringBuffer; +using ::com::sun::star::beans::XPropertySet; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::xml::sax::XAttributeList; + + +const sal_Char sAPI_Title[] = "Title"; +const sal_Char sAPI_ParaStyleHeading[] = "ParaStyleHeading"; + + +TYPEINIT1( XMLIndexTitleTemplateContext, SvXMLImportContext ); + +XMLIndexTitleTemplateContext::XMLIndexTitleTemplateContext( + SvXMLImport& rImport, + Reference<XPropertySet> & rPropSet, + sal_uInt16 nPrfx, + const OUString& rLocalName) : + SvXMLImportContext(rImport, nPrfx, rLocalName), + sStyleName(), + bStyleNameOK(sal_False), + sContent(), + rTOCPropertySet(rPropSet), + sTitle(RTL_CONSTASCII_USTRINGPARAM(sAPI_Title)), + sParaStyleHeading(RTL_CONSTASCII_USTRINGPARAM(sAPI_ParaStyleHeading)) +{ +} + + +XMLIndexTitleTemplateContext::~XMLIndexTitleTemplateContext() +{ +} + +void XMLIndexTitleTemplateContext::StartElement( + const Reference<XAttributeList> & xAttrList) +{ + // there's only one attribute: style-name + sal_Int32 nLength = xAttrList->getLength(); + for(sal_Int32 nAttr = 0; nAttr < nLength; nAttr++) + { + OUString sLocalName; + sal_uInt16 nPrefix = GetImport().GetNamespaceMap(). + GetKeyByAttrName( xAttrList->getNameByIndex(nAttr), + &sLocalName ); + if ( (XML_NAMESPACE_TEXT == nPrefix) && + (sLocalName.equalsAsciiL(sXML_style_name, + sizeof(sXML_style_name)-1)) ) + { + sStyleName = xAttrList->getValueByIndex(nAttr); + bStyleNameOK = sal_True; + } + } +} + +void XMLIndexTitleTemplateContext::EndElement() +{ + Any aAny; + + aAny <<= sContent.makeStringAndClear(); + rTOCPropertySet->setPropertyValue(sTitle, aAny); + + if (bStyleNameOK) + { + aAny <<= sStyleName; + rTOCPropertySet->setPropertyValue(sParaStyleHeading, aAny); + } +} + +void XMLIndexTitleTemplateContext::Characters( + const OUString& sString) +{ + sContent.append(sString); +} diff --git a/xmloff/source/text/XMLIndexTitleTemplateContext.hxx b/xmloff/source/text/XMLIndexTitleTemplateContext.hxx new file mode 100644 index 000000000000..88573dec467f --- /dev/null +++ b/xmloff/source/text/XMLIndexTitleTemplateContext.hxx @@ -0,0 +1,135 @@ +/************************************************************************* + * + * $RCSfile: XMLIndexTitleTemplateContext.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dvo $ $Date: 2000-11-02 15:51:18 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XMLOFF_XMLINDEXTITLETEMPLATECONTEXT_HXX_ +#define _XMLOFF_XMLINDEXTITLETEMPLATECONTEXT_HXX_ + +#ifndef _XMLOFF_XMLICTXT_HXX +#include "xmlictxt.hxx" +#endif + +#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_ +#include <com/sun/star/uno/Reference.h> +#endif + +#ifndef _RTL_USTRING_ +#include <rtl/ustring> +#endif + +#ifndef _RTL_USTRBUF_HXX_ +#include <rtl/ustrbuf.hxx> +#endif + + +namespace com { namespace sun { namespace star { + namespace beans { class XPropertySet; } + namespace xml { namespace sax { class XAttributeList; } } +} } } + + +/** + * Import index title templates + */ +class XMLIndexTitleTemplateContext : public SvXMLImportContext +{ + + const ::rtl::OUString sTitle; + const ::rtl::OUString sParaStyleHeading; + + // paragraph style + ::rtl::OUString sStyleName; + sal_Bool bStyleNameOK; + + // content + ::rtl::OUStringBuffer sContent; + + // TOC property set + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet> & rTOCPropertySet; + +public: + + TYPEINFO(); + + XMLIndexTitleTemplateContext( + SvXMLImport& rImport, + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet> & rPropSet, + sal_uInt16 nPrfx, + const ::rtl::OUString& rLocalName); + + ~XMLIndexTitleTemplateContext(); + +protected: + + /** process parameters */ + virtual void StartElement( + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList> & xAttrList); + + /** set values */ + virtual void EndElement(); + + /** pick up title characters */ + virtual void Characters(const ::rtl::OUString& sString); +}; + +#endif diff --git a/xmloff/source/text/XMLSectionImportContext.cxx b/xmloff/source/text/XMLSectionImportContext.cxx index 4906893fac3e..533667ed4768 100644 --- a/xmloff/source/text/XMLSectionImportContext.cxx +++ b/xmloff/source/text/XMLSectionImportContext.cxx @@ -2,9 +2,9 @@ * * $RCSfile: XMLSectionImportContext.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: dvo $ $Date: 2000-10-19 10:25:01 $ + * last change: $Author: dvo $ $Date: 2000-11-02 15:51:18 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -142,18 +142,22 @@ TYPEINIT1( XMLSectionImportContext, SvXMLImportContext ); const sal_Char sAPI_TextSection[] = "com.sun.star.text.TextSection"; const sal_Char sAPI_IsProtected[] = "IsProtected"; +const sal_Char sAPI_Condition[] = "Condition"; +const sal_Char sAPI_IsVisible[] = "IsVisible"; enum XMLSectionToken { XML_TOK_SECTION_STYLE_NAME, XML_TOK_SECTION_NAME, - XML_TOK_SECTION_PROTECTED + XML_TOK_SECTION_CONDITION, + XML_TOK_SECTION_DISPLAY }; static __FAR_DATA SvXMLTokenMapEntry aSectionTokenMap[] = { { XML_NAMESPACE_TEXT, sXML_style_name, XML_TOK_SECTION_STYLE_NAME }, { XML_NAMESPACE_TEXT, sXML_name, XML_TOK_SECTION_NAME }, - { XML_NAMESPACE_TEXT, sXML_protected, XML_TOK_SECTION_PROTECTED }, + { XML_NAMESPACE_TEXT, sXML_condition, XML_TOK_SECTION_CONDITION }, + { XML_NAMESPACE_TEXT, sXML_display, XML_TOK_SECTION_DISPLAY }, XML_TOKEN_MAP_END }; @@ -172,12 +176,15 @@ XMLSectionImportContext::XMLSectionImportContext( xEndRange(), xSectionPropertySet(), sTextSection(RTL_CONSTASCII_USTRINGPARAM(sAPI_TextSection)), - sIsProtected(RTL_CONSTASCII_USTRINGPARAM(sAPI_IsProtected)), + sCondition(RTL_CONSTASCII_USTRINGPARAM(sAPI_Condition)), + sIsVisible(RTL_CONSTASCII_USTRINGPARAM(sAPI_IsVisible)), sStyleName(), sName(), + sCond(), sEmpty(), bValid(sal_False), - bProtected(sal_False) + bCondOK(sal_False), + bIsVisible(sal_True) { } @@ -214,11 +221,6 @@ void XMLSectionImportContext::StartElement( Reference<XNamed> xNamed(xPropSet, UNO_QUERY); xNamed->setName(sName); - // protected? - Any aAny; - aAny.setValue( &bProtected, ::getBooleanCppuType() ); - xPropSet->setPropertyValue( sIsProtected, aAny ); - // stylename? if (sStyleName.getLength() > 0) { @@ -231,6 +233,16 @@ void XMLSectionImportContext::StartElement( } } + // IsVisible and condition + Any aAny; + aAny.setValue( &bIsVisible, ::getBooleanCppuType() ); + xPropSet->setPropertyValue( sIsVisible, aAny ); + if (bCondOK) + { + aAny <<= sCond; + xPropSet->setPropertyValue( sCondition, aAny ); + } + // insert X and paragraph mark; then insert // section over the space character, and delete the // last paragraph when closing a section. @@ -274,23 +286,33 @@ void XMLSectionImportContext::ProcessAttributes( sal_uInt16 nPrefix = GetImport().GetNamespaceMap(). GetKeyByAttrName( xAttrList->getNameByIndex(nAttr), &sLocalName ); + OUString sAttr = xAttrList->getValueByIndex(nAttr); switch (aTokenMap.Get(nPrefix, sLocalName)) { case XML_TOK_SECTION_STYLE_NAME: - sStyleName = xAttrList->getValueByIndex(nAttr); + sStyleName = sAttr; break; case XML_TOK_SECTION_NAME: - sName = xAttrList->getValueByIndex(nAttr); + sName = sAttr; bValid = sal_True; break; - case XML_TOK_SECTION_PROTECTED: - sal_Bool bTmp; - if (SvXMLUnitConverter::convertBool(bTmp, - xAttrList->getValueByIndex(nAttr))) + case XML_TOK_SECTION_CONDITION: + sCond = sAttr; + bCondOK = sal_True; + break; + case XML_TOK_SECTION_DISPLAY: + if (sAttr.equalsAsciiL(sXML_true, sizeof(sXML_true)-1)) + { + bIsVisible = sal_True; + } + else if ( sAttr.equalsAsciiL(sXML_none, sizeof(sXML_none)-1) || + sAttr.equalsAsciiL(sXML_condition, + sizeof(sXML_condition)-1) ) { - bProtected = bTmp; + bIsVisible = sal_False; } + // else: ignore break; default: ; // ignore diff --git a/xmloff/source/text/XMLSectionImportContext.hxx b/xmloff/source/text/XMLSectionImportContext.hxx index 11359c373755..4d17948261ee 100644 --- a/xmloff/source/text/XMLSectionImportContext.hxx +++ b/xmloff/source/text/XMLSectionImportContext.hxx @@ -2,9 +2,9 @@ * * $RCSfile: XMLSectionImportContext.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: dvo $ $Date: 2000-10-19 10:25:01 $ + * last change: $Author: dvo $ $Date: 2000-11-02 15:51:18 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -97,13 +97,16 @@ class XMLSectionImportContext : public SvXMLImportContext ::com::sun::star::beans::XPropertySet> xSectionPropertySet; const ::rtl::OUString sTextSection; - const ::rtl::OUString sIsProtected; + const ::rtl::OUString sCondition; + const ::rtl::OUString sIsVisible; const ::rtl::OUString sEmpty; ::rtl::OUString sStyleName; ::rtl::OUString sName; + ::rtl::OUString sCond; + sal_Bool bCondOK; + sal_Bool bIsVisible; sal_Bool bValid; - sal_Bool bProtected; public: diff --git a/xmloff/source/text/XMLTextColumnsContext.cxx b/xmloff/source/text/XMLTextColumnsContext.cxx index 9eca88d1ac7d..0897b31792d6 100644 --- a/xmloff/source/text/XMLTextColumnsContext.cxx +++ b/xmloff/source/text/XMLTextColumnsContext.cxx @@ -2,9 +2,9 @@ * * $RCSfile: XMLTextColumnsContext.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: mib $ $Date: 2000-10-30 12:47:14 $ + * last change: $Author: dvo $ $Date: 2000-11-02 15:51:18 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -435,7 +435,12 @@ void XMLTextColumnsContext::EndElement( ) return; Reference< XTextColumns > xColumns( xIfc, UNO_QUERY ); - if( pColumns && pColumns->Count() == (sal_uInt16)nCount ) + if ( 0 == nCount ) + { + // zero columns = no columns -> 1 column + xColumns->setColumnCount( 1 ); + } + else if( pColumns && pColumns->Count() == (sal_uInt16)nCount ) { sal_Int32 nRelWidth = 0; sal_uInt16 nColumnsWithWidth = 0; diff --git a/xmloff/source/text/makefile.mk b/xmloff/source/text/makefile.mk index be5a1a6d6e30..1b81a1747ad9 100644 --- a/xmloff/source/text/makefile.mk +++ b/xmloff/source/text/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.8 $ +# $Revision: 1.9 $ # -# last change: $Author: mib $ $Date: 2000-10-26 09:25:33 $ +# last change: $Author: dvo $ $Date: 2000-11-02 15:51:18 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -89,16 +89,25 @@ CXXFILES = \ txtparai.cxx \ txtprhdl.cxx \ txtprmap.cxx \ + txtsecte.cxx \ txtstyle.cxx \ txtstyli.cxx \ txtvfldi.cxx \ XMLFootnoteBodyImportContext.cxx \ XMLFootnoteConfigurationImportContext.cxx \ XMLFootnoteImportContext.cxx \ + XMLIndexSimpleEntryContext.cxx \ + XMLIndexSpanEntryContext.cxx \ + XMLIndexTabStopEntryContext.cxx \ + XMLIndexTOCContext.cxx \ + XMLIndexTOCSourceContext.cxx \ + XMLIndexTOCStylesContext.cxx \ + XMLIndexTemplateContext.cxx \ + XMLIndexTitleTemplateContext.cxx \ XMLPropertyBackpatcher.cxx \ XMLSectionImportContext.cxx \ - XMLSectionSourceImportContext.cxx \ XMLSectionSourceDDEImportContext.cxx \ + XMLSectionSourceImportContext.cxx \ XMLTextColumnsContext.cxx \ XMLTextColumnsExport.cxx \ XMLTextFrameContext.cxx \ @@ -128,16 +137,25 @@ SLOFILES = \ $(SLO)$/txtparai.obj \ $(SLO)$/txtprhdl.obj \ $(SLO)$/txtprmap.obj \ + $(SLO)$/txtsecte.obj \ $(SLO)$/txtstyle.obj \ $(SLO)$/txtstyli.obj \ $(SLO)$/txtvfldi.obj \ $(SLO)$/XMLFootnoteBodyImportContext.obj \ $(SLO)$/XMLFootnoteConfigurationImportContext.obj \ $(SLO)$/XMLFootnoteImportContext.obj \ + $(SLO)$/XMLIndexSimpleEntryContext.obj \ + $(SLO)$/XMLIndexSpanEntryContext.obj \ + $(SLO)$/XMLIndexTOCContext.obj \ + $(SLO)$/XMLIndexTOCSourceContext.obj \ + $(SLO)$/XMLIndexTOCStylesContext.obj \ + $(SLO)$/XMLIndexTabStopEntryContext.obj \ + $(SLO)$/XMLIndexTemplateContext.obj \ + $(SLO)$/XMLIndexTitleTemplateContext.obj \ $(SLO)$/XMLPropertyBackpatcher.obj \ $(SLO)$/XMLSectionImportContext.obj \ - $(SLO)$/XMLSectionSourceImportContext.obj \ $(SLO)$/XMLSectionSourceDDEImportContext.obj \ + $(SLO)$/XMLSectionSourceImportContext.obj \ $(SLO)$/XMLTextColumnsContext.obj \ $(SLO)$/XMLTextColumnsExport.obj \ $(SLO)$/XMLTextFrameContext.obj \ diff --git a/xmloff/source/text/txtflde.cxx b/xmloff/source/text/txtflde.cxx index a5380b65f943..91e29bbf116d 100644 --- a/xmloff/source/text/txtflde.cxx +++ b/xmloff/source/text/txtflde.cxx @@ -2,9 +2,9 @@ * * $RCSfile: txtflde.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: dvo $ $Date: 2000-10-20 12:45:07 $ + * last change: $Author: dvo $ $Date: 2000-11-02 15:51:18 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -261,6 +261,7 @@ static sal_Char __READONLY_DATA FIELD_SERVICE_SHEET_NAME[] = "SheetName"; static sal_Char __READONLY_DATA FIELD_SERVICE_MACRO[] = "Macro"; static sal_Char __READONLY_DATA FIELD_SERVICE_GET_REFERENCE[] = "GetReference"; static sal_Char __READONLY_DATA FIELD_SERVICE_DDE[] = "DDE"; +static sal_Char __READONLY_DATA FIELD_SERVICE_URL[] = "URL"; SvXMLEnumMapEntry __READONLY_DATA aFieldServiceNameMapping[] = @@ -325,13 +326,12 @@ SvXMLEnumMapEntry __READONLY_DATA aFieldServiceNameMapping[] = // non-writer fields { FIELD_SERVICE_SHEET_NAME, FIELD_ID_SHEET_NAME }, + { FIELD_SERVICE_URL, FIELD_ID_URL }, { 0, 0 } }; -// TODO: enable asserts (#77364#) when all fields are implemented - // property accessor helper functions inline sal_Bool const GetBoolProperty(const OUString&, @@ -414,7 +414,9 @@ XMLTextFieldExport::XMLTextFieldExport( SvXMLExport& rExp ) sPropertyIsAutomaticUpdate( RTL_CONSTASCII_USTRINGPARAM("IsAutomaticUpdate")), sPropertyDependentTextFields( - RTL_CONSTASCII_USTRINGPARAM("DependentTextFields")) + RTL_CONSTASCII_USTRINGPARAM("DependentTextFields")), + sPropertyURL(RTL_CONSTASCII_USTRINGPARAM("URL")), + sPropertyTargetFrame(RTL_CONSTASCII_USTRINGPARAM("TargetFrame")) { } @@ -477,8 +479,7 @@ enum FieldIdEnum XMLTextFieldExport::MapFieldName( nTmp, sFieldName, aFieldServiceNameMapping); // check return - // #77364#: no assert, unless all fields are implemented - // DBG_ASSERT(bRet, "Unknown field service name encountered!"); + DBG_ASSERT(bRet, "Unknown field service name encountered!"); if (! bRet) { nToken = FIELD_ID_UNKNOWN; @@ -637,6 +638,7 @@ enum FieldIdEnum XMLTextFieldExport::MapFieldName( case FIELD_ID_CHAPTER: case FIELD_ID_FILE_NAME: case FIELD_ID_SHEET_NAME: + case FIELD_ID_URL: ; // these field IDs are final break; @@ -736,6 +738,7 @@ sal_Bool XMLTextFieldExport::IsStringField( case FIELD_ID_AUTHOR: case FIELD_ID_PAGESTRING: case FIELD_ID_SHEET_NAME: + case FIELD_ID_URL: // always string: return sal_True; @@ -853,13 +856,13 @@ void XMLTextFieldExport::ExportFieldAutoStyle( case FIELD_ID_CHAPTER: case FIELD_ID_FILE_NAME: case FIELD_ID_SHEET_NAME: + case FIELD_ID_URL: ; // no formats for these fields! break; case FIELD_ID_UNKNOWN: default: - // #77364#: no assert, unless all fields are implemented - // DBG_ERROR("unkown field type!"); + DBG_ERROR("unkown field type!"); // ignore -> no format for unkowns break; } @@ -1407,10 +1410,32 @@ void XMLTextFieldExport::ExportField(const Reference<XTextField> & rTextField ) ExportElement(sXML_sheet_name, sPresentation); break; + case FIELD_ID_URL: + { + // this field is a special case because it gets mapped onto a + // hyperlink, rather than one of the regular text field. We + // can't use our helper functions, as the assume namespace + // text. + OUString sHref = GetStringProperty(sPropertyURL, xPropSet); + if (sHref.getLength()>0) + { + rExport.AddAttribute(XML_NAMESPACE_XLINK, sXML_href, sHref); + } + OUString sTarget = GetStringProperty(sPropertyTargetFrame,xPropSet); + if (sTarget.getLength()>0) + { + rExport.AddAttribute(XML_NAMESPACE_OFFICE, sXML_target_frame_name, + sTarget); + } + SvXMLElementExport aUrlField(rExport, XML_NAMESPACE_TEXT, sXML_a, + sal_False, sal_False); + GetExport().GetDocHandler()->characters(sPresentation); + break; + } + case FIELD_ID_UNKNOWN: default: - // #77364#: no assert, unless all fields are implemented - // DBG_ERROR("unkown field type encountered!"); + DBG_ERROR("unkown field type encountered!"); // always export content GetExport().GetDocHandler()->characters(sPresentation); } diff --git a/xmloff/source/text/txtfldi.cxx b/xmloff/source/text/txtfldi.cxx index a1f7c2a10506..f5b88655ceaf 100644 --- a/xmloff/source/text/txtfldi.cxx +++ b/xmloff/source/text/txtfldi.cxx @@ -2,9 +2,9 @@ * * $RCSfile: txtfldi.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: dvo $ $Date: 2000-10-20 12:45:07 $ + * last change: $Author: dvo $ $Date: 2000-11-02 15:51:18 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -269,6 +269,7 @@ const sal_Char sAPI_macro[] = "Macro"; const sal_Char sAPI_dde[] = "DDE"; const sal_Char sAPI_get_reference[] = "GetReference"; const sal_Char sAPI_sheet_name[] = "SheetName"; +const sal_Char sAPI_url[] = "URL"; // property names const sal_Char sAPI_is_fixed[] = "IsFixed"; @@ -313,6 +314,8 @@ const sal_Char sAPI_reference_field_source[] = "ReferenceFieldSource"; const sal_Char sAPI_dde_command_type[] = "DDECommandType"; const sal_Char sAPI_dde_command_file[] = "DDECommandFile"; const sal_Char sAPI_dde_command_element[] = "DDECommandElement"; +// sAPI_url: also used as service name +const sal_Char sAPI_target_frame[] = "TargetFrame"; const sal_Char sAPI_true[] = "TRUE"; @@ -365,6 +368,10 @@ static __FAR_DATA SvXMLTokenMapEntry aTextFieldAttrTokenMap[] = { XML_NAMESPACE_TEXT, sXML_ref_name, XML_TOK_TEXTFIELD_REF_NAME }, { XML_NAMESPACE_TEXT, sXML_connection_name, XML_TOK_TEXTFIELD_CONNECTION_NAME }, + { XML_NAMESPACE_XLINK, sXML_href, XML_TOK_TEXTFIELD_HREF }, + { XML_NAMESPACE_OFFICE, sXML_target_frame_name, + XML_TOK_TEXTFIELD_TARGET_FRAME }, + XML_TOKEN_MAP_END }; @@ -2984,3 +2991,59 @@ void XMLSheetNameImportContext::PrepareField( { // no attributes -> nothing to be done } + + +// +// URL fields (Calc, Impress, Draw) +// + +TYPEINIT1(XMLUrlFieldImportContext, XMLTextFieldImportContext); + +XMLUrlFieldImportContext::XMLUrlFieldImportContext( + SvXMLImport& rImport, + XMLTextImportHelper& rHlp, + sal_uInt16 nPrfx, + const OUString& sLocalName) : + XMLTextFieldImportContext(rImport, rHlp, sAPI_url, + nPrfx, sLocalName), + sPropertyURL(RTL_CONSTASCII_USTRINGPARAM(sAPI_url)), + sPropertyTargetFrame(RTL_CONSTASCII_USTRINGPARAM(sAPI_target_frame)), + bFrameOK(sal_False) +{ +} + +void XMLUrlFieldImportContext::ProcessAttribute( + sal_uInt16 nAttrToken, + const OUString& sAttrValue ) +{ + switch (nAttrToken) + { + case XML_TOK_TEXTFIELD_HREF: + sURL = sAttrValue; + bValid = sal_True; + break; + case XML_TOK_TEXTFIELD_TARGET_FRAME: + sFrame = sAttrValue; + bFrameOK = sal_True; + break; + default: + // ignore + break; + } +} + +void XMLUrlFieldImportContext::PrepareField( + const Reference<XPropertySet> & xPropertySet) +{ + Any aAny; + + aAny <<= sURL; + xPropertySet->setPropertyValue(sPropertyURL, aAny); + + if (bFrameOK) + { + aAny <<= sFrame; + xPropertySet->setPropertyValue(sPropertyTargetFrame, aAny); + } +} + diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx index 5dd07d9d2d00..0be968ed0b20 100644 --- a/xmloff/source/text/txtimp.cxx +++ b/xmloff/source/text/txtimp.cxx @@ -2,9 +2,9 @@ * * $RCSfile: txtimp.cxx,v $ * - * $Revision: 1.18 $ + * $Revision: 1.19 $ * - * last change: $Author: mib $ $Date: 2000-10-31 09:00:40 $ + * last change: $Author: dvo $ $Date: 2000-11-02 15:51:18 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -161,6 +161,9 @@ #ifndef _XMLOFF_XMLSECTIONIMPORTCONTEXT_HXX_ #include "XMLSectionImportContext.hxx" #endif +#ifndef _XMLOFF_XMLINDEXTOCCONTEXT_HXX_ +#include "XMLIndexTOCContext.hxx" +#endif using namespace ::rtl; @@ -190,6 +193,7 @@ static __FAR_DATA SvXMLTokenMapEntry aTextElemTokenMap[] = { XML_NAMESPACE_TEXT, sXML_sequence_decls, XML_TOK_TEXT_SEQUENCE_DECLS }, { XML_NAMESPACE_TEXT, sXML_dde_connection_decls, XML_TOK_TEXT_DDE_DECLS }, { XML_NAMESPACE_TEXT, sXML_section, XML_TOK_TEXT_SECTION }, + { XML_NAMESPACE_TEXT, sXML_table_of_content, XML_TOK_TEXT_TOC }, XML_TOKEN_MAP_END }; @@ -956,11 +960,13 @@ SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext( } break; -// disable sections until section implementation is sufficient -// case XML_TOK_TEXT_SECTION: -// pContext = new XMLSectionImportContext( rImport, nPrefix, rLocalName ); -// break; + case XML_TOK_TEXT_SECTION: + pContext = new XMLSectionImportContext( rImport, nPrefix, rLocalName ); + break; + case XML_TOK_TEXT_TOC: + pContext = new XMLIndexTOCContext( rImport, nPrefix, rLocalName ); + break; } // if( !pContext ) diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx index cbc35d089792..f178ed1e135e 100644 --- a/xmloff/source/text/txtparae.cxx +++ b/xmloff/source/text/txtparae.cxx @@ -2,9 +2,9 @@ * * $RCSfile: txtparae.cxx,v $ * - * $Revision: 1.16 $ + * $Revision: 1.17 $ * - * last change: $Author: mib $ $Date: 2000-10-31 09:00:40 $ + * last change: $Author: dvo $ $Date: 2000-11-02 15:51:18 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -526,245 +526,6 @@ void XMLTextParagraphExport::exportListChange( } -void XMLTextParagraphExport::exportListAndSectionChange( - Reference<XTextSection> & rPrevSection, - const Reference<XTextContent> & rNextSectionContent, - const XMLTextNumRuleInfo& rPrevRule, - const XMLTextNumRuleInfo& rNextRule, - sal_Bool bAutoStyles) -{ - // currently, section import does not work properly; thus, we also - // disable section import. Simply call exportSectionChange - - if (!bAutoStyles) - { - exportListChange(rPrevRule, rNextRule); - } - - -// Reference<XTextSection> xNextSection; -// -// // first: get current XTextSection -// Reference<XPropertySet> xPropSet(rNextSectionContent, UNO_QUERY); -// if (xPropSet.is()) -// { -// if (xPropSet->getPropertySetInfo()->hasPropertyByName(sTextSection)) -// { -// Any aAny = xPropSet->getPropertyValue(sTextSection); -// aAny >>= xNextSection; -// } -// // else: no current section -// } -// // else: no current section -// -// // careful: exportListChange may only be called for (!bAutoStyles) -// // I'd like a cleaner solution! Maybe export all section styles upfront. -// if ( bAutoStyles ) -// { -// if ( xNextSection.is() ) -// { -// Reference<XPropertySet> xPropSet( xNextSection, UNO_QUERY); -// Add( XML_STYLE_FAMILY_TEXT_SECTION, xPropSet ); -// } -// } -// else -// { -// // old != new? -> start/equal? -// if (rPrevSection != xNextSection) -// { -// // a new section started, or an old one gets closed! -// -// // close old list -// XMLTextNumRuleInfo aEmptyNumRule; -// exportListChange(rPrevRule, aEmptyNumRule); -// -// // build stacks of old and new sections -// vector<Reference<XTextSection> > aOldStack; -// Reference<XTextSection> aCurrent = rPrevSection; -// while(aCurrent.is()) -// { -// aOldStack.push_back(aCurrent); -// aCurrent = aCurrent->getParentSection(); -// } -// -// vector<Reference<XTextSection> > aNewStack; -// aCurrent = xNextSection; -// while(aCurrent.is()) -// { -// aNewStack.push_back(aCurrent); -// aCurrent = aCurrent->getParentSection(); -// } -// -// // compare the two stacks -// vector<Reference<XTextSection> > ::reverse_iterator aOld = -// aOldStack.rbegin(); -// vector<Reference<XTextSection> > ::reverse_iterator aNew = -// aNewStack.rbegin(); -// while ( (aOld != aOldStack.rend()) && -// (aNew != aNewStack.rend()) && -// (*aOld) == (*aNew) ) -// { -// aOld++; -// aNew++; -// } -// -// // close all elements of aOld, open all of aNew -// while (aOld != aOldStack.rend()) -// { -// Reference<XNamed> xName(*aOld, UNO_QUERY); -// GetExport().GetDocHandler()->endElement(sText_Section); -// GetExport().GetDocHandler()->ignorableWhitespace( -// GetExport().sWS ); -// aOld++; -// } -// -// while (aNew != aNewStack.rend()) -// { -// exportSectionStart(*aNew); -// aNew++; -// } -// -// // start new list -// exportListChange(aEmptyNumRule, rNextRule); -// } -// else -// { -// // list change, if sections have not changed -// exportListChange(rPrevRule, rNextRule); -// } -// } -// -// // save old section (old numRule gets saved in calling method -// rPrevSection = xNextSection; -} - -void XMLTextParagraphExport::exportSectionStart( - const ::com::sun::star::uno::Reference < - ::com::sun::star::text::XTextSection > & rSection) -{ - // any old attributes? - GetExport().CheckAttrList(); - - Reference<XNamed> xName(rSection, UNO_QUERY); - GetExport().AddAttribute(XML_NAMESPACE_TEXT, sXML_name, - xName->getName()); - - // get XPropertySet for other values - Reference<XPropertySet> xPropSet(rSection, UNO_QUERY); - Any aAny; - - // style name - GetExport().AddAttribute(XML_NAMESPACE_TEXT, sXML_style_name, - Find( XML_STYLE_FAMILY_TEXT_SECTION, - xPropSet, sEmpty )); - - // protected - aAny = xPropSet->getPropertyValue(sIsProtected); - if (*(sal_Bool*)aAny.getValue()) - { - GetExport().AddAttributeASCII(XML_NAMESPACE_TEXT, - sXML_protected, sXML_true); - } - - // condition and display - aAny = xPropSet->getPropertyValue(sCondition); - OUString sCond; - aAny >>= sCond; - sal_Char* pDisplay; - if (sCond.getLength() > 0) - { - GetExport().AddAttribute(XML_NAMESPACE_TEXT, sXML_condition, - sCond); - pDisplay = sXML_condition; - } - else - { - pDisplay = sXML_none; - } - aAny = xPropSet->getPropertyValue(sIsVisible); - if (! *(sal_Bool*)aAny.getValue()) - { - GetExport().AddAttributeASCII(XML_NAMESPACE_TEXT, sXML_display, - pDisplay); - } - - // export element - GetExport().GetDocHandler()->ignorableWhitespace( GetExport().sWS ); - GetExport().GetDocHandler()->startElement( sText_Section, - GetExport().GetXAttrList() ); - GetExport().ClearAttrList(); - - // data source - // unfortunately, we have to test all relevant strings for non-zero length - aAny = xPropSet->getPropertyValue(sFileLink); - SectionFileLink aFileLink; - aAny >>= aFileLink; - - aAny = xPropSet->getPropertyValue(sLinkRegion); - OUString sRegionName; - aAny >>= sRegionName; - - if ( (aFileLink.FileURL.getLength() > 0) || - (aFileLink.FilterName.getLength() > 0) || - (sRegionName.getLength() > 0) ) - { - if (aFileLink.FileURL.getLength() > 0) - { - GetExport().AddAttribute(XML_NAMESPACE_XLINK, sXML_href, - aFileLink.FileURL); - } - - if (aFileLink.FilterName.getLength() > 0) - { - GetExport().AddAttribute(XML_NAMESPACE_TEXT, sXML_filter_name, - aFileLink.FilterName); - } - - if (sRegionName.getLength() > 0) - { - GetExport().AddAttribute(XML_NAMESPACE_TEXT, sXML_section_name, - sRegionName); - } - - SvXMLElementExport aElem(GetExport(), - XML_NAMESPACE_TEXT, sXML_section_source, - sal_True, sal_True); - } - else - { - // data source DDE - // unfortunately, we have to test all relevant strings for - // non-zero length - aAny = xPropSet->getPropertyValue(sDdeCommandFile); - OUString sApplication; - aAny >>= sApplication; - aAny = xPropSet->getPropertyValue(sDdeCommandType); - OUString sTopic; - aAny >>= sTopic; - aAny = xPropSet->getPropertyValue(sDdeCommandElement); - OUString sItem; - aAny >>= sItem; - - if ( (sApplication.getLength() > 0) || - (sTopic.getLength() > 0) || - (sItem.getLength() > 0 ) ) - { - GetExport().AddAttribute(XML_NAMESPACE_TEXT, sXML_dde_application, - sApplication); - GetExport().AddAttribute(XML_NAMESPACE_TEXT, sXML_dde_topic, - sTopic); - GetExport().AddAttribute(XML_NAMESPACE_TEXT, sXML_dde_item, - sItem); - - SvXMLElementExport aElem(GetExport(), - XML_NAMESPACE_TEXT, - sXML_section_source_dde, - sal_True, sal_True); - } - // else: no data source - } -} - XMLTextParagraphExport::XMLTextParagraphExport( SvXMLExport& rExp, SvXMLAutoStylePoolP & rASP ) : @@ -849,6 +610,16 @@ XMLTextParagraphExport::XMLTextParagraphExport( sDdeCommandFile(RTL_CONSTASCII_USTRINGPARAM("DDECommandFile")), sDdeCommandType(RTL_CONSTASCII_USTRINGPARAM("DDECommandType")), sDdeCommandElement(RTL_CONSTASCII_USTRINGPARAM("DDECommandElement")), + sDocumentIndex(RTL_CONSTASCII_USTRINGPARAM("DocumentIndex")), + sCreateFromOutline(RTL_CONSTASCII_USTRINGPARAM("CreateFromOutline")), + sLevel(RTL_CONSTASCII_USTRINGPARAM("Level")), + sCreateFromMarks(RTL_CONSTASCII_USTRINGPARAM("CreateFromMarks")), + sCreateFromChapter(RTL_CONSTASCII_USTRINGPARAM("CreateFromChapter")), + sLevelFormat(RTL_CONSTASCII_USTRINGPARAM("LevelFormat")), + sTitle(RTL_CONSTASCII_USTRINGPARAM("Title")), + sParaStyleHeading(RTL_CONSTASCII_USTRINGPARAM("ParaStyleHeading")), + sParaStyleLevel(RTL_CONSTASCII_USTRINGPARAM("ParaStyleLevel")), + sLevelParagraphStyles(RTL_CONSTASCII_USTRINGPARAM("LevelParagraphStyles")), sEmpty() { sText_Section = GetExport().GetNamespaceMap().GetQNameByKey( diff --git a/xmloff/source/text/txtparai.cxx b/xmloff/source/text/txtparai.cxx index e1f027d14771..5a7a4aa9c8df 100644 --- a/xmloff/source/text/txtparai.cxx +++ b/xmloff/source/text/txtparai.cxx @@ -2,9 +2,9 @@ * * $RCSfile: txtparai.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: dvo $ $Date: 2000-10-26 09:18:20 $ + * last change: $Author: dvo $ $Date: 2000-11-02 15:51:18 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -80,6 +80,12 @@ #ifndef _COM_SUN_STAR_TEXT_XTEXTCURSOR_HPP_ #include <com/sun/star/text/XTextCursor.hpp> #endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSETINFO_HPP_ +#include <com/sun/star/beans/XPropertySetInfo.hpp> +#endif #ifndef _COM_SUN_STAR_TEXT_CONTROLCHARACTER_HPP_ #include <com/sun/star/text/ControlCharacter.hpp> #endif @@ -673,11 +679,33 @@ SvXMLImportContext *XMLImpSpanContext_Impl::CreateChildContext( break; case XML_TOK_TEXT_HYPERLINK: - pContext = new XMLImpHyperlinkContext_Impl( rImport, nPrefix, - rLocalName, xAttrList, - rHints, - rIgnoreLeadingSpace ); + { + // test for HyperLinkURL property. If present, insert link as + // text property (StarWriter), else try to insert as text + // field (StarCalc, StarDraw, ...) + Reference<beans::XPropertySet> xPropSet( + rImport.GetTextImport()->GetCursor(), + UNO_QUERY ); + + const OUString sHyperLinkURL( + RTL_CONSTASCII_USTRINGPARAM("HyperLinkURL")); + + if (xPropSet->getPropertySetInfo()->hasPropertyByName(sHyperLinkURL)) + { + pContext = new XMLImpHyperlinkContext_Impl( rImport, nPrefix, + rLocalName, xAttrList, + rHints, + rIgnoreLeadingSpace ); + } + else + { + pContext = new XMLUrlFieldImportContext( rImport, + *rImport.GetTextImport().get(), + nPrefix, rLocalName); + + } break; + } case XML_TOK_TEXT_ENDNOTE: case XML_TOK_TEXT_FOOTNOTE: diff --git a/xmloff/source/text/txtprmap.cxx b/xmloff/source/text/txtprmap.cxx index f76a2b576999..1943e86af1e2 100644 --- a/xmloff/source/text/txtprmap.cxx +++ b/xmloff/source/text/txtprmap.cxx @@ -2,9 +2,9 @@ * * $RCSfile: txtprmap.cxx,v $ * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * - * last change: $Author: mib $ $Date: 2000-10-30 12:04:28 $ + * last change: $Author: dvo $ $Date: 2000-11-02 15:51:18 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -188,7 +188,7 @@ XMLPropertyMapEntry aXMLParaPropMap[] = // RES_PARATR_WIDOWS M_E( "ParaWidows", FO, widows, XML_TYPE_NUMBER8, 0 ), // RES_PARATR_TABSTOP - M_E( "ParaTabStops", STYLE, tabstop_tab_stops, MID_FLAG_ELEMENT_ITEM|XML_TYPE_TEXT_TABSTOP, CTF_TABSTOP ), // this is not realy a string! + M_E( "ParaTabStops", STYLE, tab_stops, MID_FLAG_ELEMENT_ITEM|XML_TYPE_TEXT_TABSTOP, CTF_TABSTOP ), // this is not realy a string! // RES_PARATR_HYPHENZONE M_E( "ParaIsHyphenation", FO, hyphenate, XML_TYPE_BOOL, 0 ), M_E( "ParaHyphenationMaxLeadingChars", FO, hyphenation_remain_char_count, XML_TYPE_NUMBER, 0 ), @@ -504,6 +504,7 @@ XMLPropertyMapEntry aXMLFramePropMap[] = XMLPropertyMapEntry aXMLSectionPropMap[] = { M_E( "TextColumns", STYLE, columns, MID_FLAG_ELEMENT_ITEM|XML_TYPE_TEXT_COLUMNS, CTF_TEXTCOLUMNS ), + M_E( "IsProtected", STYLE, protect, XML_TYPE_BOOL, 0 ), { 0, 0, 0, 0 } }; diff --git a/xmloff/source/text/txtsecte.cxx b/xmloff/source/text/txtsecte.cxx new file mode 100644 index 000000000000..2f8e38c1dca0 --- /dev/null +++ b/xmloff/source/text/txtsecte.cxx @@ -0,0 +1,872 @@ +/************************************************************************* + * + * $RCSfile: txtsecte.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dvo $ $Date: 2000-11-02 15:51:18 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _XMLOFF_TXTPARAE_HXX +#include "txtparae.hxx" +#endif + +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif + +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif + +#ifndef _RTL_USTRBUF_HXX_ +#include <rtl/ustrbuf.hxx> +#endif + +#ifndef __SGI_STL_VECTOR +#include <stl/vector> +#endif + + +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif + +#ifndef _COM_SUN_STAR_CONTAINER_XINDEXREPLACE_HPP_ +#include <com/sun/star/container/XIndexReplace.hpp> +#endif + +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif + +#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ +#include <com/sun/star/beans/PropertyValue.hpp> +#endif + +#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUES_HPP_ +#include <com/sun/star/beans/PropertyValues.hpp> +#endif + +#ifndef _COM_SUN_STAR_BEANS_PROPERTYSTATE_HPP_ +#include <com/sun/star/beans/PropertyState.hpp> +#endif + +#ifndef _COM_SUN_STAR_TEXT_XTEXT_HPP_ +#include <com/sun/star/text/XText.hpp> +#endif + +#ifndef _COM_SUN_STAR_TEXT_XTEXTSECTION_HPP_ +#include <com/sun/star/text/XTextSection.hpp> +#endif + +#ifndef _COM_SUN_STAR_TEXT_SECTIONFILELINK_HPP_ +#include <com/sun/star/text/SectionFileLink.hpp> +#endif + +#ifndef _COM_SUN_STAR_CONTAINER_XNAMED_HPP_ +#include <com/sun/star/container/XNamed.hpp> +#endif + +#ifndef _COM_SUN_STAR_TEXT_XDOCUMENTINDEX_HPP_ +#include <com/sun/star/text/XDocumentIndex.hpp> +#endif + +#ifndef _XMLOFF_XMLKYWD_HXX +#include "xmlkywd.hxx" +#endif + +#ifndef _XMLOFF_XMLNMSPE_HXX +#include "xmlnmspe.hxx" +#endif + +#ifndef _XMLOFF_FAMILIES_HXX_ +#include "families.hxx" +#endif + +#ifndef _XMLOFF_XMLUCONV_HXX +#include "xmluconv.hxx" +#endif + +#ifndef _XMLOFF_NMSPMAP_HXX +#include "nmspmap.hxx" +#endif + +#ifndef _XMLOFF_XMLEXP_HXX +#include "xmlexp.hxx" +#endif + +#ifndef _XMLOFF_XMLTKMAP_HXX +#include "xmltkmap.hxx" +#endif + +#ifndef _XMLOFF_XMLTEXTNUMRULEINFO_HXX +#include "XMLTextNumRuleInfo.hxx" +#endif + +using namespace ::com::sun::star; +using namespace ::com::sun::star::text; +using namespace ::com::sun::star::uno; +using namespace ::std; + +using ::rtl::OUString; +using ::rtl::OUStringBuffer; +using ::com::sun::star::beans::XPropertySet; +using ::com::sun::star::beans::PropertyValue; +using ::com::sun::star::beans::PropertyValues; +using ::com::sun::star::beans::PropertyState; +using ::com::sun::star::container::XIndexReplace; +using ::com::sun::star::container::XNamed; +using ::com::sun::star::lang::XServiceInfo; + + +void XMLTextParagraphExport::exportListAndSectionChange( + Reference<XTextSection> & rPrevSection, + const Reference<XTextContent> & rNextSectionContent, + const XMLTextNumRuleInfo& rPrevRule, + const XMLTextNumRuleInfo& rNextRule, + sal_Bool bAutoStyles) +{ + Reference<XTextSection> xNextSection; + + // first: get current XTextSection + Reference<XPropertySet> xPropSet(rNextSectionContent, UNO_QUERY); + if (xPropSet.is()) + { + if (xPropSet->getPropertySetInfo()->hasPropertyByName(sTextSection)) + { + Any aAny = xPropSet->getPropertyValue(sTextSection); + aAny >>= xNextSection; + } + // else: no current section + + if (xPropSet->getPropertySetInfo()->hasPropertyByName(sDocumentIndex)) + { + Any aAny = xPropSet->getPropertyValue(sDocumentIndex); + Reference<XDocumentIndex> xDocumentIndex; + aAny >>= xDocumentIndex; + + if (xDocumentIndex.is() && !rPrevSection.is()) + { + exportDocumentIndex(xDocumentIndex, bAutoStyles); + } + } + } + // else: no current section + + // careful: exportListChange may only be called for (!bAutoStyles) + // I'd like a cleaner solution! Maybe export all section styles upfront. + if ( bAutoStyles ) + { + if ( xNextSection.is() ) + { + Reference<XPropertySet> xPropSet( xNextSection, UNO_QUERY); + Add( XML_STYLE_FAMILY_TEXT_SECTION, xPropSet ); + } + } + else + { + // old != new? -> start/equal? + if (rPrevSection != xNextSection) + { + // a new section started, or an old one gets closed! + + // close old list + XMLTextNumRuleInfo aEmptyNumRule; + exportListChange(rPrevRule, aEmptyNumRule); + + // build stacks of old and new sections + vector<Reference<XTextSection> > aOldStack; + Reference<XTextSection> aCurrent = rPrevSection; + while(aCurrent.is()) + { + aOldStack.push_back(aCurrent); + aCurrent = aCurrent->getParentSection(); + } + + vector<Reference<XTextSection> > aNewStack; + aCurrent = xNextSection; + while(aCurrent.is()) + { + aNewStack.push_back(aCurrent); + aCurrent = aCurrent->getParentSection(); + } + + // compare the two stacks + vector<Reference<XTextSection> > ::reverse_iterator aOld = + aOldStack.rbegin(); + vector<Reference<XTextSection> > ::reverse_iterator aNew = + aNewStack.rbegin(); + while ( (aOld != aOldStack.rend()) && + (aNew != aNewStack.rend()) && + (*aOld) == (*aNew) ) + { + aOld++; + aNew++; + } + + // close all elements of aOld, open all of aNew + while (aOld != aOldStack.rend()) + { + Reference<XNamed> xName(*aOld, UNO_QUERY); + GetExport().GetDocHandler()->ignorableWhitespace( + GetExport().sWS ); + GetExport().GetDocHandler()->endElement(sText_Section); + GetExport().GetDocHandler()->ignorableWhitespace( + GetExport().sWS ); + aOld++; + } + + while (aNew != aNewStack.rend()) + { + exportSectionStart(*aNew); + aNew++; + } + + // start new list + exportListChange(aEmptyNumRule, rNextRule); + } + else + { + // list change, if sections have not changed + exportListChange(rPrevRule, rNextRule); + } + } + + // save old section (old numRule gets saved in calling method + rPrevSection = xNextSection; +} + +void XMLTextParagraphExport::exportSectionStart( + const ::com::sun::star::uno::Reference < + ::com::sun::star::text::XTextSection > & rSection) +{ + // any old attributes? + GetExport().CheckAttrList(); + + Reference<XNamed> xName(rSection, UNO_QUERY); + GetExport().AddAttribute(XML_NAMESPACE_TEXT, sXML_name, + xName->getName()); + + // get XPropertySet for other values + Reference<XPropertySet> xPropSet(rSection, UNO_QUERY); + Any aAny; + + // style name + GetExport().AddAttribute(XML_NAMESPACE_TEXT, sXML_style_name, + Find( XML_STYLE_FAMILY_TEXT_SECTION, + xPropSet, sEmpty )); + + // condition and display + aAny = xPropSet->getPropertyValue(sCondition); + OUString sCond; + aAny >>= sCond; + sal_Char* pDisplay; + if (sCond.getLength() > 0) + { + GetExport().AddAttribute(XML_NAMESPACE_TEXT, sXML_condition, + sCond); + pDisplay = sXML_condition; + } + else + { + pDisplay = sXML_none; + } + aAny = xPropSet->getPropertyValue(sIsVisible); + if (! *(sal_Bool*)aAny.getValue()) + { + GetExport().AddAttributeASCII(XML_NAMESPACE_TEXT, sXML_display, + pDisplay); + } + + // export element + GetExport().GetDocHandler()->ignorableWhitespace( GetExport().sWS ); + GetExport().GetDocHandler()->startElement( sText_Section, + GetExport().GetXAttrList() ); + GetExport().ClearAttrList(); + + // data source + // unfortunately, we have to test all relevant strings for non-zero length + aAny = xPropSet->getPropertyValue(sFileLink); + SectionFileLink aFileLink; + aAny >>= aFileLink; + + aAny = xPropSet->getPropertyValue(sLinkRegion); + OUString sRegionName; + aAny >>= sRegionName; + + if ( (aFileLink.FileURL.getLength() > 0) || + (aFileLink.FilterName.getLength() > 0) || + (sRegionName.getLength() > 0) ) + { + if (aFileLink.FileURL.getLength() > 0) + { + GetExport().AddAttribute(XML_NAMESPACE_XLINK, sXML_href, + aFileLink.FileURL); + } + + if (aFileLink.FilterName.getLength() > 0) + { + GetExport().AddAttribute(XML_NAMESPACE_TEXT, sXML_filter_name, + aFileLink.FilterName); + } + + if (sRegionName.getLength() > 0) + { + GetExport().AddAttribute(XML_NAMESPACE_TEXT, sXML_section_name, + sRegionName); + } + + SvXMLElementExport aElem(GetExport(), + XML_NAMESPACE_TEXT, sXML_section_source, + sal_True, sal_True); + } + else + { + // data source DDE + // unfortunately, we have to test all relevant strings for + // non-zero length + aAny = xPropSet->getPropertyValue(sDdeCommandFile); + OUString sApplication; + aAny >>= sApplication; + aAny = xPropSet->getPropertyValue(sDdeCommandType); + OUString sTopic; + aAny >>= sTopic; + aAny = xPropSet->getPropertyValue(sDdeCommandElement); + OUString sItem; + aAny >>= sItem; + + if ( (sApplication.getLength() > 0) || + (sTopic.getLength() > 0) || + (sItem.getLength() > 0 ) ) + { + GetExport().AddAttribute(XML_NAMESPACE_TEXT, sXML_dde_application, + sApplication); + GetExport().AddAttribute(XML_NAMESPACE_TEXT, sXML_dde_topic, + sTopic); + GetExport().AddAttribute(XML_NAMESPACE_TEXT, sXML_dde_item, + sItem); + + SvXMLElementExport aElem(GetExport(), + XML_NAMESPACE_TEXT, + sXML_section_source_dde, + sal_True, sal_True); + } + // else: no data source + } +} + +void XMLTextParagraphExport::exportDocumentIndex( + Reference<XDocumentIndex> & rIndex, + sal_Bool bAutoStyles) +{ + OUString sServiceName = rIndex->getServiceName(); + + const sal_Char sAPI_ContentIndex[] = "com.sun.star.text.ContentIndex"; + + if (sServiceName.equalsAsciiL(sAPI_ContentIndex, + sizeof(sAPI_ContentIndex)-1)) + { + Reference<XPropertySet> xPropertySet(rIndex, UNO_QUERY); + + if (bAutoStyles) + { + // treat index as section style + Add( XML_STYLE_FAMILY_TEXT_SECTION, xPropertySet ); + } + else + { + Any aAny; + + // style name + GetExport().AddAttribute(XML_NAMESPACE_TEXT, sXML_style_name, + Find( XML_STYLE_FAMILY_TEXT_SECTION, + xPropertySet, sEmpty )); + + // table of content Element + SvXMLElementExport aElem(GetExport(), + XML_NAMESPACE_TEXT, + sXML_table_of_content, + sal_True, sal_True); + + { + // scope for table-of-content-source element + + // outline-level (none|1..10) + aAny = xPropertySet->getPropertyValue(sCreateFromOutline); + if (*(sal_Bool*)aAny.getValue()) + { + // outline-level: 1..10 + aAny = xPropertySet->getPropertyValue(sLevel); + sal_Int16 nLevel; + aAny >>= nLevel; + + OUStringBuffer sBuffer; + SvXMLUnitConverter::convertNumber(sBuffer, + (sal_Int32)nLevel); + + GetExport().AddAttribute(XML_NAMESPACE_TEXT, + sXML_outline_level, + sBuffer.makeStringAndClear()); + } + else + { + // outline-level: none + GetExport().AddAttributeASCII(XML_NAMESPACE_TEXT, + sXML_outline_level, + sXML_none); + } + + // use index marks + aAny = xPropertySet->getPropertyValue(sCreateFromMarks); + if (! (*(sal_Bool*)aAny.getValue())) + { + GetExport().AddAttributeASCII(XML_NAMESPACE_TEXT, + sXML_use_index_marks, + sXML_true); + } + + // document or chapter index? + aAny = xPropertySet->getPropertyValue(sCreateFromChapter); + if (*(sal_Bool*)aAny.getValue()) + { + GetExport().AddAttributeASCII(XML_NAMESPACE_TEXT, + sXML_index_scope, + sXML_chapter); + } + + // the TOC source element + SvXMLElementExport aElem(GetExport(), + XML_NAMESPACE_TEXT, + sXML_table_of_content_source, + sal_True, sal_True); + + // styles from which to build the index (LevelParagraphStyles) + aAny = xPropertySet->getPropertyValue(sLevelParagraphStyles); + Reference<XIndexReplace> xLevelParagraphStyles; + aAny >>= xLevelParagraphStyles; + + // iterate over levels + sal_Int32 nPLevelCount = xLevelParagraphStyles->getCount(); + for(sal_Int32 nLevel = 0; nLevel < nPLevelCount; nLevel++) + { + aAny = xLevelParagraphStyles->getByIndex(nLevel); + Sequence<OUString> aStyleNames; + aAny >>= aStyleNames; + + // export only if at least one style is contained + sal_Int32 nNamesCount = aStyleNames.getLength(); + if (nNamesCount > 0) + { + + // level attribute; we count 1..10; API 0..9 + OUStringBuffer sBuf; + sal_Int32 nLevelPlusOne = nLevel + 1; + SvXMLUnitConverter::convertNumber(sBuf, nLevelPlusOne); + GetExport().AddAttribute(XML_NAMESPACE_TEXT, + sXML_outline_level, + sBuf.makeStringAndClear()); + + // source styles element + SvXMLElementExport aParaStyles(GetExport(), + XML_NAMESPACE_TEXT, + sXML_index_source_styles, + sal_True, sal_True); + + // iterate over styles in this level + for(sal_Int32 nName = 0; nName < nNamesCount; nName++) + { + // stylename attribute + GetExport().AddAttribute(XML_NAMESPACE_TEXT, + sXML_style_name, + aStyleNames[nName]); + + // element + SvXMLElementExport aParaStyle(GetExport(), + XML_NAMESPACE_TEXT, + sXML_index_source_style, + sal_True, sal_False); + } + } + } + + // scope for title template + { + // header style name + aAny = xPropertySet->getPropertyValue(sParaStyleHeading); + OUString sStyleName; + aAny >>= sStyleName; + GetExport().AddAttribute(XML_NAMESPACE_TEXT, + sXML_style_name, + sStyleName); + + // title template + SvXMLElementExport aHeaderTemplate(GetExport(), + XML_NAMESPACE_TEXT, + sXML_index_title_template, + sal_True, sal_False); + + // title as element content + aAny = xPropertySet->getPropertyValue(sTitle); + OUString sTitleString; + aAny >>= sTitleString; + GetExport().GetDocHandler()->characters(sTitleString); + } + + // export level templates + aAny = xPropertySet->getPropertyValue(sLevelFormat); + Reference<XIndexReplace> xLevelTemplates; + aAny >>= xLevelTemplates; + + // iterate over level formats; + // skip element 0 (empty template for title) + sal_Int32 nLevelCount = xLevelTemplates->getCount(); + for(sal_Int32 i = 1; i<nLevelCount; i++) + { + // level number + OUStringBuffer sBuffer; + SvXMLUnitConverter::convertNumber(sBuffer, i); + OUString sNumber = sBuffer.makeStringAndClear(); + + GetExport().AddAttribute(XML_NAMESPACE_TEXT, + sXML_outline_level, + sNumber); + + // style name + sBuffer.append(sParaStyleLevel); + sBuffer.append(i); + aAny = xPropertySet->getPropertyValue( + sBuffer.makeStringAndClear()); + OUString sLevelStyle; + aAny >>= sLevelStyle; + GetExport().AddAttribute(XML_NAMESPACE_TEXT, + sXML_style_name, + sLevelStyle); + + // template element + SvXMLElementExport aLevelTemplate(GetExport(), + XML_NAMESPACE_TEXT, + sXML_index_entry_template, + sal_True, sal_True); + + // get sequence + Sequence<PropertyValues> aTemplateSequence; + aAny = xLevelTemplates->getByIndex(i); + aAny >>= aTemplateSequence; + + // export sequence + sal_Int32 nTemplateCount = aTemplateSequence.getLength(); + for(sal_Int32 nTemplateNo = 0; + nTemplateNo < nTemplateCount; + nTemplateNo++) + { + exportIndexTemplateElement( + aTemplateSequence[nTemplateNo]); + } + } + } + + { + SvXMLElementExport aIndexBody(GetExport(), + XML_NAMESPACE_TEXT, + sXML_table_of_content_body, + sal_True, sal_True); + } + } + } +} + + +enum TemplateTypeEnum +{ + TOK_TTYPE_ENTRY_NUMBER, + TOK_TTYPE_ENTRY_TEXT, + TOK_TTYPE_TAB_STOP, + TOK_TTYPE_TEXT, + TOK_TTYPE_PAGE_NUMBER, + TOK_TTYPE_CHAPTER_INFO, + TOK_TTYPE_HYPERLINK_START, + TOK_TTYPE_HYPERLINK_END, + TOK_TTYPE_BIBLIOGRAPHY, + TOK_TTYPE_INVALID +}; + +enum TemplateParamEnum +{ + TOK_TPARAM_TOKEN_TYPE, + TOK_TPARAM_CHAR_STYLE, + TOK_TPARAM_TAB_RIGHT_ALIGNED, + TOK_TPARAM_TAB_POSITION, + TOK_TPARAM_TAB_FILL_CHAR, + TOK_TPARAM_TEXT, + TOK_TPARAM_CHAPTER_FORMAT +}; + +SvXMLEnumMapEntry __READONLY_DATA aTemplateTypeMap[] = +{ + { "TokenEntryNumber", TOK_TTYPE_ENTRY_NUMBER }, + { "TokenEntryText", TOK_TTYPE_ENTRY_TEXT }, + { "TokenTabStop", TOK_TTYPE_TAB_STOP }, + { "TokenText", TOK_TTYPE_TEXT }, + { "TokenPageNumber", TOK_TTYPE_PAGE_NUMBER }, + { "TokenChapterInfo", TOK_TTYPE_CHAPTER_INFO }, + { "TokenHyperlinkStart", TOK_TTYPE_HYPERLINK_START }, + { "TokenHyperlinkEnd", TOK_TTYPE_HYPERLINK_END }, + { "TokenBibliogaphyDataField", TOK_TTYPE_BIBLIOGRAPHY }, + { NULL, NULL } +}; + +SvXMLEnumMapEntry __READONLY_DATA aTemplateParamMap[] = +{ + { "TokenType", TOK_TPARAM_TOKEN_TYPE }, + { "CharacterStyleName", TOK_TPARAM_CHAR_STYLE }, + { "TabStopRightAligned", TOK_TPARAM_TAB_RIGHT_ALIGNED }, + { "TabStopPosition", TOK_TPARAM_TAB_POSITION }, + { "TabStopFillCharacter", TOK_TPARAM_TAB_FILL_CHAR }, + { "Text", TOK_TPARAM_TEXT }, + { "ChapterFormat", TOK_TPARAM_CHAPTER_FORMAT }, + { NULL, NULL } +}; + +void XMLTextParagraphExport::exportIndexTemplateElement( + Sequence<PropertyValue> & rValues) +{ + + // variables for template values + + // char style + OUString sCharStyle; + sal_Bool bCharStyleOK = sal_False; + + // text + OUString sText; + sal_Bool bTextOK = sal_False; + + // tab position + sal_Bool bRightAligned = sal_False; + sal_Bool bRightAlignedOK = sal_False; + + // tab position + sal_Int32 nTabPosition = 0; + sal_Bool bTabPositionOK = sal_False; + + // fill character + OUString sFillChar; + sal_Bool bFillCharOK = sal_False; + + // chapter format + sal_Int16 nChapterFormat; + sal_Bool bChapterFormatOK = sal_False; + + + // token type + enum TemplateTypeEnum nTokenType = TOK_TTYPE_INVALID; + + sal_Int32 nCount = rValues.getLength(); + for(sal_Int32 i = 0; i<nCount; i++) + { + sal_uInt16 nToken; + if ( SvXMLUnitConverter::convertEnum( nToken, rValues[i].Name, + aTemplateParamMap ) ) + { + // Only use direct and default values. + // Wrong. no property states, so ignore. + // if ( (beans::PropertyState_DIRECT_VALUE == rValues[i].State) || + // (beans::PropertyState_DEFAULT_VALUE == rValues[i].State) ) + + switch (nToken) + { + case TOK_TPARAM_TOKEN_TYPE: + { + sal_uInt16 nTmp; + OUString sVal; + rValues[i].Value >>= sVal; + if (SvXMLUnitConverter::convertEnum( nTmp, sVal, + aTemplateTypeMap)) + { + nTokenType = (enum TemplateTypeEnum)nTmp; + } + break; + } + + case TOK_TPARAM_CHAR_STYLE: + // only valid, if not empty + rValues[i].Value >>= sCharStyle; + bCharStyleOK = sCharStyle.getLength() > 0; + break; + + case TOK_TPARAM_TEXT: + rValues[i].Value >>= sText; + bTextOK = sal_True; + break; + + case TOK_TPARAM_TAB_RIGHT_ALIGNED: + bRightAligned = + *(sal_Bool *)rValues[i].Value.getValue(); + bRightAlignedOK = sal_True; + break; + + case TOK_TPARAM_TAB_POSITION: + rValues[i].Value >>= nTabPosition; + bTabPositionOK = sal_True; + break; + + case TOK_TPARAM_TAB_FILL_CHAR: + rValues[i].Value >>= sFillChar; + bFillCharOK = sal_True; + break; + + case TOK_TPARAM_CHAPTER_FORMAT: + rValues[i].Value >>= nChapterFormat; + bChapterFormatOK = sal_True; + break; + } + } + } + + // convert type to token (and check validity) ... + sal_Char* pElement = NULL; + switch(nTokenType) + { + case TOK_TTYPE_ENTRY_TEXT: + pElement = sXML_index_entry_text; + break; + case TOK_TTYPE_TAB_STOP: + // test validity + pElement = ( bRightAligned || bTabPositionOK || bFillCharOK ) + ? sXML_index_entry_tab_stop : NULL; + break; + case TOK_TTYPE_TEXT: + // test validity + pElement = bTextOK ? sXML_index_entry_span : NULL; + break; + case TOK_TTYPE_PAGE_NUMBER: + pElement = sXML_index_entry_page_number; + break; + case TOK_TTYPE_CHAPTER_INFO: // keyword index + case TOK_TTYPE_ENTRY_NUMBER: // table of content + // sanitize format: both as chapter fields + pElement = sXML_index_entry_chapter; + break; + case TOK_TTYPE_HYPERLINK_START: + pElement = sXML_index_entry_link_start; + break; + case TOK_TTYPE_HYPERLINK_END: + pElement = sXML_index_entry_link_end; + break; + case TOK_TTYPE_BIBLIOGRAPHY: + pElement = sXML_index_entry_bibliography; + default: + ; // unknown/unimplemented template + break; + } + + // ... and write Element + if (pElement != NULL) + { + // character style (for most templates) + if (bCharStyleOK) + { + switch (nTokenType) + { + case TOK_TTYPE_ENTRY_TEXT: + case TOK_TTYPE_TEXT: + case TOK_TTYPE_PAGE_NUMBER: + case TOK_TTYPE_ENTRY_NUMBER: + case TOK_TTYPE_HYPERLINK_START: + case TOK_TTYPE_HYPERLINK_END: + GetExport().AddAttribute(XML_NAMESPACE_TEXT, + sXML_style_name, sCharStyle); + break; + default: + ; // nothing: no character style + break; + } + } + + if (TOK_TTYPE_TAB_STOP == nTokenType) + { + // tab type + GetExport().AddAttributeASCII(XML_NAMESPACE_STYLE, + sXML_type, + bRightAligned ? sXML_right : sXML_left); + + if (! bRightAligned) + { + // position for left tabs (convert to measure) + OUStringBuffer sBuf; + GetExport().GetMM100UnitConverter().convertMeasure(sBuf, + nTabPosition); + GetExport().AddAttribute(XML_NAMESPACE_STYLE, + sXML_position, + sBuf.makeStringAndClear()); + } + + // fill char ("leader char") + GetExport().AddAttribute(XML_NAMESPACE_STYLE, sXML_leader_char, + sFillChar); + } + + // export template + SvXMLElementExport aTemplateElement(GetExport(), XML_NAMESPACE_TEXT, + pElement, sal_True, sal_False); + + // entry text or span element: write text + if (TOK_TTYPE_TEXT == nTokenType) + { + GetExport().GetDocHandler()->characters(sText); + } + } +} |