/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License version 3 * only, as published by the Free Software Foundation. * * OpenOffice.org is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License version 3 for more details * (a copy is included in the LICENSE file that accompanied this code). * * You should have received a copy of the GNU Lesser General Public License * version 3 along with OpenOffice.org. If not, see * * for a copy of the LGPLv3 License. * ************************************************************************/ /// @HTML #ifndef SW_MS_MSFILTER_HXX #define SW_MS_MSFILTER_HXX #include #include #include # include //SwTwips # include //String # include "wwstyles.hxx" //ww::sti # include //rtl_TextEncoding # include //Size #include #include // fuer den Attribut Stack #include #include #include #define CREATE_CONST_ASC(s) String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM(s)) class SwDoc; class SwPaM; class String; class SwTableNode; class SwNodeIndex; class SwNoTxtNode; class SwTxtNode; class WW8TabDesc; namespace myImplHelpers { template class StyleMapperImpl; } class SwTxtFmtColl; class SwCharFmt; typedef myImplHelpers::StyleMapperImpl ParaMapper; typedef myImplHelpers::StyleMapperImpl CharMapper; namespace sw { namespace ms { /** MSOffice appears to set the charset of unicode fonts to MS 932 Arial Unicode MS for example is a unicode font, but word sets exported uses of it to the MS 932 charset @param eTextEncoding the OOo encoding to convert from @return a msoffice equivalent charset identifier @author Caolán McNamara */ sal_uInt8 rtl_TextEncodingToWinCharset(rtl_TextEncoding eTextEncoding); /** Import a MSWord XE field. Suitable for .doc and .rtf @param rDoc the document to insert into @param rPaM the position in the document to insert into @param rXE the arguments of the original word XE field @author Caolán McNamara */ void ImportXE(SwDoc &rDoc, SwPaM &rPaM, const String &rXE); /** Convert from DTTM to Writer's DateTime @author Martin MaherMartin MaherMartin MaherMartin MaherMartin MaherCaolán McNamara */ SwTwips MakeSafePositioningValue(SwTwips nIn); /** Knows which writer style a given word style should be imported as Mapping a word style to a writer style has to consider mapping the word builtin styles like "Normal" as the default root style to our default root style which is called "Default" in english, and "Normal" in german. Additionally it then has to avoid name collisions such as a) styles "Normal" and "Default" in a single document, where we can use the original distinct names "Normal" and "Default" and.. b) styles "Normal" and "Default" in a single document, where we can not use the original names, and must come up with an alternative name for one of them.. And it needs to report to the importer if the style being mapped to was already in existance, for the cut and paste/insert file mode we should not modify the returned style if it is already in use as it is does not belong to us to change. @author Caolán McNamara */ class ParaStyleMapper { private: //I hate these things stupid pImpl things, but its warranted here ParaMapper *mpImpl; public: ParaStyleMapper(SwDoc &rDoc); ~ParaStyleMapper(); /** StyleResult StyleResult is a std::pair of a pointer to a style and a flag which is true if the style existed previously in the document. */ typedef std::pair StyleResult; /** Get the writer style which the word style should map to @param rName The name of the word style @param eSti The style id of the word style, we are really only interested in knowing if the style has either a builtin standard id, or is a user defined style. @return The equivalent writer style packaged as a StyleResult to use for this word style. It will only return a failure in the pathological case of catastropic failure elsewhere of there exist already styles rName and WW-rName[0..SAL_MAX_INT32], which is both unlikely and impossible. */ StyleResult GetStyle(const String& rName, ww::sti eSti); }; /** Knows which writer style a given word style should be imported as Mapping a word style to a writer style has to consider mapping the word builtin styles like "Normal" as the default root style to our default root style which is called "Default" in english, and "Normal" in german. Additionally it then has to avoid name collisions such as a) styles "Normal" and "Default" in a single document, where we can use the original distinct names "Normal" and "Default" and.. b) styles "Normal" and "Default" in a single document, where we can not use the original names, and must come up with an alternative name for one of them.. And it needs to report to the importer if the style being mapped to was already in existance, for the cut and paste/insert file mode we should not modify the returned style if it is already in use as it is does not belong to us to change. @author Caolán McNamara */ class CharStyleMapper { private: //I hate these things stupid pImpl things, but its warranted here CharMapper *mpImpl; public: CharStyleMapper(SwDoc &rDoc); ~CharStyleMapper(); /** StyleResult StyleResult is a std::pair of a pointer to a style and a flag which is true if the style existed previously in the document. */ typedef std::pair StyleResult; /** Get the writer style which the word style should map to @param rName The name of the word style @param eSti The style id of the word style, we are really only interested in knowing if the style has either a builtin standard id, or is a user defined style. @return The equivalent writer style packaged as a StyleResult to use for this word style. It will only return a failure in the pathological case of catastropic failure elsewhere of there exist already styles rName and WW-rName[0..SAL_MAX_INT32], which is both unlikely and impossible. */ StyleResult GetStyle(const String& rName, ww::sti eSti); }; /** Find suitable names for exporting this font Given a fontname description find the best primary and secondary fallback font to use from MSWord's persp font @author Caolán McNamara @see #i10242#/#i19164# for examples */ class FontMapExport { public: String msPrimary; String msSecondary; bool HasDistinctSecondary() const; FontMapExport(const String &rFontDescription); }; class InsertedTableClient : public SwClient { public: InsertedTableClient(SwTableNode & rNode); SwTableNode * GetTableNode(); }; /** Handle requirements for table formatting in insert->file mode. When inserting a table into a document which already has been formatted and laid out (e.g using insert->file) then tables must be handled in a special way, (or so previous comments and code in the filters leads me to believe). Before the document is finalized the new tables need to have their layout frms deleted and recalculated. This TableManager detects the necessity to do this, and all tables inserted into a document should be registered with this manager with InsertTable, and before finialization DelAndMakeTblFrms should be called. @author Caolán McNamara @see #i25782# for examples */ class InsertedTablesManager { public: typedef std::map TblMap; typedef TblMap::iterator TblMapIter; void DelAndMakeTblFrms(); void InsertTable(SwTableNode &rTableNode, SwPaM &rPaM); InsertedTablesManager(const SwDoc &rDoc); private: bool mbHasRoot; TblMap maTables; }; /** @author Martin Maher */ class RedlineStack { private: std::vector maStack; typedef std::vector::reverse_iterator myriter; SwDoc &mrDoc; public: explicit RedlineStack(SwDoc &rDoc) : mrDoc(rDoc) {} void open(const SwPosition& rPos, const SfxPoolItem& rAttr); bool close(const SwPosition& rPos, RedlineType_t eType); void close(const SwPosition& rPos, RedlineType_t eType, WW8TabDesc* pTabDesc ); void closeall(const SwPosition& rPos); ~RedlineStack(); private: //No copying RedlineStack(const RedlineStack&); RedlineStack& operator=(const RedlineStack&); }; /** @author Martin Maher */ class SetInDocAndDelete { private: SwDoc &mrDoc; public: explicit SetInDocAndDelete(SwDoc &rDoc) : mrDoc(rDoc) {} void operator()(SwFltStackEntry *pEntry); private: //No assignment SetInDocAndDelete& operator=(const SetInDocAndDelete&); }; /** @author Martin Maher */ class CloseIfOpen //Subclass from something ? { private: const SwPosition &mrPos; public: explicit CloseIfOpen(const SwPosition &rPos) : mrPos(rPos) {} void operator()(SwFltStackEntry *pEntry) const { if (pEntry->bLocked) pEntry->SetEndPos(mrPos); } private: //No assignment CloseIfOpen& operator=(const CloseIfOpen&); }; /** @author Martin Maher */ class CompareRedlines: public std::binary_function { public: bool operator()(const SwFltStackEntry *pOneE, const SwFltStackEntry *pTwoE) const; }; class WrtRedlineAuthor { protected: std::vector maAuthors; // Array of Sw - Bookmarknames USHORT GetPos( const String& rNm ); //No copying WrtRedlineAuthor(const WrtRedlineAuthor&); WrtRedlineAuthor& operator=(const WrtRedlineAuthor&); public: WrtRedlineAuthor() {} virtual ~WrtRedlineAuthor() {} USHORT AddName( const String& rNm ); virtual void Write(Writer &rWrt) = 0; // std::vector GetNames(); }; /** Given a SwNoTxtNode (ole/graphic) get original size Get the uncropped and unscaled size of the underlying graphic or ole object associated with a given SwNoTxtNode. This function will swap in the graphic if it is swapped out from the graphic or object cache, but will swap it out if that was the case, i.e. rNd is logically unchanged before and after GetSwappedInSize, though not physically const @param rNd the SwNoTxtNode whose objects original size we want @return the uncropped unscaled size of the SwNoTxtNode @author Caolán McNamara */ Size GetSwappedInSize(const SwNoTxtNode& rNd); struct CharRunEntry { xub_StrLen mnEndPos; sal_uInt16 mnScript; rtl_TextEncoding meCharSet; bool mbRTL; CharRunEntry(xub_StrLen nEndPos, sal_uInt16 nScript, rtl_TextEncoding eCharSet, bool bRTL) : mnEndPos(nEndPos), mnScript(nScript), meCharSet(eCharSet), mbRTL(bRTL) { } }; typedef std::vector CharRuns; typedef CharRuns::const_iterator cCharRunIter; /** Collect the ranges of Text which share Word generally requires characters which share the same direction, the same script, and occasionally (depending on the format) the same charset to be exported in independant chunks. So this function finds these ranges and returns a STL container of CharRuns @param rTxtNd The TextNode we want to ranges from @param nStart The position in the TxtNode to start processing from @param bSplitOnCharSet Set to true is we want to split on ranges of characters that share a plausible charset for export to e.g. WW7- or perhaps RTF format, not necessary for a unicode aware format like WW8+ @return STL container of CharRuns which describe the shared direction, script and optionally script of the contigious sequences of characters @author Caolán McNamara @see #i22537# for example */ CharRuns GetPseudoCharRuns(const SwTxtNode& rTxtNd, xub_StrLen nStart = 0, bool bSplitOnCharSet = false); } } #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */