summaryrefslogtreecommitdiff
path: root/sw/source/core/unocore
diff options
context:
space:
mode:
authorKurt Zenker <kz@openoffice.org>2009-09-11 14:29:45 +0000
committerKurt Zenker <kz@openoffice.org>2009-09-11 14:29:45 +0000
commitb01573861cdcb32619c7745055e14823b865a12d (patch)
tree632325b85479698f9beaa9d208b15606d6609c75 /sw/source/core/unocore
parent5f4f7fb1531ed52fa9cda9be690ecca162c3fb19 (diff)
CWS-TOOLING: integrate CWS odfmetadata3
2009-09-11 Michael Stahl merge DEV300_m58 2009-09-07 Michael Stahl SwFmtFld::Modify(): do nothing on RES_OBJECTDYING 2009-08-27 Michael Stahl #i91565#, #i91566#: TextPortionEnumerationTest.java: add test document 2009-08-27 Michael Stahl #i91565#, #i91566#: add complex test: TextPortionEnumerationTest.java 2009-08-27 Michael Stahl CLiteral::initialize(): zero-length literals probably not an error 2009-08-27 Michael Stahl #i91565#, #i91566#: offapi: new InContentMetadata and MetadataField services adapt TextPortion for InContentMetadata 2009-08-27 Michael Stahl #i91564#: xmloff: load/store xml:id and RDFa for text:bookmark(-start). 2009-08-27 Michael Stahl #i91564#: sw core: add support for xml:id at bookmarks: sw::mark::Bookmark: derive from Metadatable. SwHistoryBookmark, SaveBookmark: store a MetadatableUndo. ndcopy.cxx: lcl_CopyBookmarks(): copy the xml:id. SwXBookmark: derive from MetadatableMixin. 2009-08-27 Michael Stahl #i91565#, #i91566#: xmloff: refactor ruby import so nested meta(-field) works: remove XMLRubyHint_Impl. XMLImpRubyContext_Impl::~XMLImpRubyContext_Impl(): insert ruby directly. 2009-08-27 Michael Stahl #i91565#, #i91566#: xmloff: fix text:meta(-field) import/export: new XMLTextParagraphExport::exportTextField() overload for XTextField. CreateAndInsertMark(): set xml:id after insertion. fix meta(-field) service names, bugs etc. 2009-08-27 Michael Stahl #i91565#, #i91566#: sw text formatting: paint background of meta(-field) body: SwFont: add member m_nMetaCount. txttypes.hxx: add POR_META. atrstck.cxx: handle RES_TXTATR_META(FIELD). itrform2.cxx: SwTxtFormatter::WhichTxtPor(): create new class SwMetaPortion. 2009-08-27 Michael Stahl #i91566#: sw text formatting: display meta-field prefix and suffix: SwAttrIter::GetAttr(): replace with call to GetTxtAttrForCharAt(). SwTxtFormatter::NewExtraPortion(): handle meta-field prefix. SwTxtFormatter: new member m_nHintEndIndex. SwTxtFormatter::WhichFirstPortion(): call TryNewNoLengthPortion(). SwTxtFormatter::TryNewNoLengthPortion(): new; handle suffix of meta-field. SwTxtFormatter::UnderFlow(): UGLY HACK: decrement m_nHintEndIndex. SwFldPortion: add flag m_bNoLength: portion has zero length (for suffix). 2009-08-27 Michael Stahl #i91565#, #i91566#: extend text:meta(-field) uno wrapper with XText interface: unoobj.hxx: new CursorType CURSOR_META. unoobj2.cxx: refactor SwXText implementation to ensure that when the SwXText belongs to a SwXMeta, content is always inserted inside the meta(-field). unoobj.cxx: new SwXTextCursor::ForceIntoMeta(): cursor stays in meta(-field). unometa.hxx: SwXMeta implements XText, forwarding to a member SwXMetaText. DocInsertStringSplitCR(), SwX*::attachToRange(), SwX*::DeleteAndInsert(): use FORCEHINTEXPAND hack to ensure insert into the meta(-field) at the end. 2009-08-27 Michael Stahl #i91565#, #i91566#: add text:meta(-field) uno wrapper to sw: fmtmeta.hxx, fmtatr2.cxx: new class sw::MetaField, new sw::MetaFieldManager. doc.hxx, docnew.cxx: new SwDoc::GetMetaFieldManager(). unocoll.hxx,.cxx: new SW_SERVICE_FIELDTYPE_METAFIELD, SW_SERVICE_TYPE_META. unomap.hxx,.cxx: new PROPERTY_MAP_METAFIELD. unoprnms.hxx: new UNO_NAME_META. unoport.hxx: new PORTION_META; add "InContentMetadata" prop to SwXTextPortion. new unometa.hxx: new class SwXMeta and SwXMetaField. unofield.cxx: SwXFieldEnumeration: include meta-fields. unoportenum.cxx: handle RES_TXTATR_META(FIELD) by using a portion list stack. unotext.cxx: SwXText::insertTextContent(): handle meta(-field) as attribute. 2009-08-27 Michael Stahl #i91565#, #i91566#: ndhints.cxx: remove sort number from SwTxtAttrNesting 2009-08-27 Michael Stahl #i91565#, #i91566#: add support for hints with end and CH_TXTATR to sw core: doc.hxx, docedt.cxx: replace SwDoc::Delete(), DeleteAndJoin(), ReplaceRange() with wrappers that split at left-overlapped end+CH_TXTATR hints. txatbase.hxx: new member SwTxtAttr::m_bHasDummyChar. ndtxt.hxx: rename SwTxtNode::GetTxtAttr() to GetTxtAttrForCharAt(). ndtxt.cxx: SwTxtNode::CopyText(): copy end+CH_TXTATR hints iff copy CH_TXTATR. txtatr2.cxx, thints.cxx: SwTxtMeta gets a CH_TXTATR. 2009-08-27 Michael Stahl #i91565#, #i91566#: add text:meta(-field) to sw core: txatbase.hxx: new member SwTxtAttr::m_bNesting. hintids.hxx: new ids RES_TXTATR_META, RES_TXTATR_METAFIELD. txtatr.hxx: new base class SwTxtAttrNesting. new hint SwTxtMeta. SwTxtRuby derives from SwTxtAttrNesting. txtinet.hxx: SwTxtINetFmt derives from SwTxtAttrNesting. new header fmtmeta.hxx: new pool item SwFmtMeta. new class sw::Meta. ndhints.hxx, thints.cxx: new method SwpHints::TryInsertNesting(). thints.cxx: refactoring: BuildPortions() no longer handles Ruby/Hyperlink, but TryInsertNesting(), which also handles meta(-field). SwTxtNode::InsertItem(): check if the hint is actually inserted. ndhints.cxx: sort nesting hints based on sort number. ndtxt.cxx: lcl_CopyHint(): handle copy of meta/meta-field. 2009-08-27 Michael Stahl enable expanding hints with m_bLockExpandFlag set: add new InsertFlag: INS_FORCEHINTEXPAND. add new SetAttrMode: SETATTR_FORCEHINTEXPAND. rename SwEditShell::Insert() to Insert2() because changed signature fails to compile when SwWrtShell tries to overwrite these non-virtual members... SwWrtShell::Insert() sets FOCEHINTEXPAND if range was selected/deleted. adapt SwUndoInsert to store flags. 2009-08-27 Michael Stahl change formal parameters of item insertion methods to type SetAttrMode 2009-08-27 Michael Stahl fix incorrect resetting of text attributes in SwUndoInsSection, SwUndoInserts 2009-08-27 Michael Stahl clean up SwTxtNode::CutImpl() and lcl_CopyHint() 2009-08-27 Michael Stahl rename SwDoc::Copy() to CopyRange(), and _Copy() to CopyImpl() 2009-08-27 Michael Stahl rename SwNodes::Move() to MoveRange(), and remove unused parameter 2009-08-27 Michael Stahl rename SwDoc::Move() to MoveRange()/MoveNodeRange() 2009-08-27 Michael Stahl rename SwDoc::Insert() to InsertString(), and remove sal_Unicode variant 2009-08-27 Michael Stahl rename SwDoc::Insert() to InsertPoolItem()/InsertItemSet()/InsertSwSection() 2009-08-27 Michael Stahl rename SwDoc::Replace() to ReplaceRange() 2009-08-27 Michael Stahl remove SwDoc::Overwrite() sal_Unicode variant 2009-08-27 Michael Stahl split up SwDoc::DeleteAndJoin(): factor out DeleteAndJoinWithRedline() 2009-08-27 Michael Stahl rename overloaded SwDoc::Delete() to DeleteRange()/DeleteTOXMark() 2009-08-27 Michael Stahl rename SwTxtNode::Copy() to CopyText() 2009-08-27 Michael Stahl rename SwTxtNode::Cut() to CutText(), and _Cut() to CutImpl() 2009-08-27 Michael Stahl rename SwTxtNode::Delete() to DeleteAttribute()/DeleteAttributes() 2009-08-27 Michael Stahl rename SwTxtNode::Replace() to ReplaceText(), and remove the xub_Unicode variant 2009-08-27 Michael Stahl rename SwTxtNode::Erase() to EraseText() 2009-08-27 Michael Stahl rename SwTxtNode::Insert() to InsertText(), and remove the xub_Unicode variant 2009-08-27 Michael Stahl clean up SwTxtNode::Update() 2009-08-27 Michael Stahl remove SwTxtAttr::RemoveFromPool() and make destructor non-public, to be invoked by new method SwTxtAttr::Destroy() 2009-08-27 Michael Stahl ensure that SwDoc::Insert() for item (set) returns success indicator: replace SwRegHistory constructor with method InsertItems(), returning bool. refactor InsAttr() so that it checks if InsertItems() succeeds. 2009-08-27 Michael Stahl move SwXTextPortionEnumeration from unoobj.hxx to unoport.hxx 2009-08-27 Michael Stahl add missing SolarMutex in SwXTextPortion methods 2009-08-27 Michael Stahl SwXTextPortion: new member m_xTextField (so the TextField property need not be returned indirectly via SwUnoCursorHelper). factor out function CreateSwXTextField(). 2009-08-27 Michael Stahl SwXTextPortion: remove PORTION_CONTROL_CHAR and implementation of XTextField 2009-08-27 Michael Stahl remove obsolete hint SwTxtHardBlank and formats SwFmtHardBlank/SwFmtSoftHyph 2009-08-27 Michael Stahl clean up SwTxtAttr and friends: remove many accessor methods for obsolete (due to autofmt) char format items. remove unused flag SwTxtAttr::m_bDontMergeAttr. MakeRedlineTxtAttr() now dedicated function, no longer calls MakeTxtAttr(). 2009-08-27 Michael Stahl remove obsolete attribute SwTxt2Lines 2009-08-27 Michael Stahl SwXTextPortionEnumeration: finish refactoring CreatePortions change ExportHints so it always returns a text portion for hint w/ CH_TXTATR. remove special case for handling end of paragraph. unfortunately had to refactor the fieldmarks export as well (got in the way). 2009-08-27 Michael Stahl SwXTextPortionEnumeration: refactor CreatePortions: frames export extract function ExportFrames() from CreatePortions(). remove (un)dead code that calls evil MovePara(fnParaCurr, fnParaEnd) 2009-08-27 Michael Stahl clean up SwXParaFrameEnumeration 2009-08-27 Michael Stahl CollectFrameAtNode: replace SwDependArr with STL based FrameDependList_t 2009-08-27 Michael Stahl SwXTextPortionEnumeration: tweak refmark/toxmark export so ExportHints returns the portion for point marks 2009-08-27 Michael Stahl clean up SwXTextPortionEnumeration: prefix members, remove casts, replace SvWeirdArray with STL, etc. make CreatePortions() method a function, and remove lots of members. extract fieldmarks function from CreatePortions. 2009-08-27 Michael Stahl remove FOREACHUNOPAM_START/END macros 2009-08-27 Michael Stahl clean up SwXTextPortion: prefix members, remove casts, etc. remove SwXRubyPortion: replace it with another SwXTextPortion constructor 2009-08-27 Michael Stahl #i102541# SwXReferenceMark::InsertRefMark(): use flag SETATTR_DONTEXPAND 2009-08-27 Michael Stahl rename SwTxtNode::Insert to SwTxtNode::InsertHint, and fix constness in SwTxtNode::InsertItem 2009-08-27 Michael Stahl turn SwTxtNode::MakeTxtAttr() methods into global functions in ndhints.hxx 2009-08-27 Michael Stahl remove obsolete sw/inc/bookmrk.hxx 2009-08-27 Michael Stahl pam.cxx: fix ComparePosition functions (returned wrong result in one case) 2009-08-27 Michael Stahl #i103613# only import RDF metadata on normal open of a document 2009-09-11 kz CWS-TOOLING: integrate CWS impress176 2009-09-08 20:18:24 +0200 sj r275957 : fixed warning (shadowed variable) 2009-09-08 18:02:05 +0200 cl r275948 : #i104315# added missing tab pages 2009-09-08 17:35:18 +0200 cl r275947 : #i104866# fixed angle import 2009-09-08 17:32:53 +0200 cl r275946 : #i104841# fixed angle import 2009-09-08 17:01:25 +0200 cl r275943 : #i103935# fixed the SID_EVENTCONFIG mess 2009-09-08 14:32:57 +0200 sj r275928 : #i104685# only comments 2009-09-07 12:37:36 +0200 sj r275886 : #i104683# fixed import of bold/italic attributes for normal text shapes 2009-09-04 15:07:46 +0200 sj r275808 : #104689# fixed bullet color problem 2009-09-03 15:25:07 +0200 sj r275753 : #160200# added vertical alignment of table cells 2009-09-11 kz CWS-TOOLING: integrate CWS dv14 2009-09-10 15:16:32 +0200 sg r276035 : #160513# updated wfs scheme to accept ports 2009-09-10 07:41:47 +0200 dv r276019 : #i104942# Better renaming algorithmen 2009-08-31 13:41:11 +0200 dv r275604 : #160505# Setting APP1PRODUCTNAME must not overwrite APP1PRODUCTDEF 2009-09-11 kz CWS-TOOLING: integrate CWS jl131 2009-09-02 16:42:40 +0200 jl r275720 : #i97896# 2009-08-31 13:01:53 +0200 jl r275599 : CWS-TOOLING: rebase CWS jl131 to trunk@275331 (milestone: DEV300:m56) 2009-07-31 14:35:30 +0200 jl r274531 : CWS-TOOLING: rebase CWS jl131 to trunk@274203 (milestone: DEV300:m53) 2009-07-23 14:20:32 +0200 jl r274272 : #i79839# better error text when trying to modify shared layer without having write permission, eg. unopkg add --shared, unopkg remove --shared, unopkg reinstall --shared 2009-07-22 16:38:02 +0200 jl r274252 : #i97896# localize error message for lock file 2009-07-22 16:37:22 +0200 jl r274251 : #i80462# unprecise wording in updatedialog 2009-07-22 16:36:06 +0200 jl r274250 : #i97896# localize error message for lock file 2009-07-22 16:35:20 +0200 jl r274249 : #i97896# localize error message for lock file 2009-07-22 15:07:30 +0200 jl r274242 : #i98873# minimum java version is 1.5 since OOo 3.0 2009-09-11 kz CWS-TOOLING: integrate CWS changehc 2009-08-31 19:38:50 +0200 pl r275633 : remove dbug printf 2009-08-31 17:41:50 +0200 pl r275623 : CWS-TOOLING: rebase CWS changehc to trunk@275331 (milestone: DEV300:m56) 2009-07-15 19:45:46 +0200 pl r274028 : #i35482# use HC flag to decide high contrast mode 2009-07-15 17:40:52 +0200 pl r274020 : #i35482# use HC flag to decide high contrast mode 2009-07-15 17:39:50 +0200 pl r274019 : #i35482# update autohc correctly in MergeSystemSettings 2009-07-15 17:38:57 +0200 pl r274018 : #i35482# update autohc correctly in MergeSystemSettings 2009-09-11 kz CWS-TOOLING: integrate CWS notes10 2009-08-24 07:25:57 +0200 mod r275287 : 2009-07-26 02:38:32 +0200 mod r274343 : #i#i103645# 2009-07-26 02:01:53 +0200 mod r274342 : #i103645# 2009-07-26 01:52:42 +0200 mod r274341 : #i103490# 2009-07-22 08:31:48 +0200 mod r274215 : #i103373# 2009-07-15 00:55:11 +0200 mod r273987 : #i101419# 2009-07-14 07:07:55 +0200 mod r273956 : #i101419# 2009-07-14 07:07:43 +0200 mod r273955 : #i101419# 2009-07-14 07:02:10 +0200 mod r273954 : changes from notes9 2009-07-14 06:14:25 +0200 mod r273953 : #i103476# 2009-09-11 kz CWS-TOOLING: integrate CWS ab70 2009-09-10 15:12:54 +0200 jsk r276034 : #i85434# - mandatory automatic update test 2009-09-10 15:11:06 +0200 jsk r276033 : #i85434# - mandatory automatic update test 2009-09-02 09:49:24 +0200 ab r275698 : #i85434# Dialog Import 2009-09-11 kz CWS-TOOLING: integrate CWS hb32bugs02 2009-09-02 Henning Brinkmann #i102420# revert changes 2009-08-26 Henning Brinkmann merged DEV300_m56 2009-08-19 Henning Brinkmann merged DEV300_m55 2009-08-14 Henning Brinkmann merged changes from wntmsci12 2009-08-12 Henning Brinkmann Implemented NoSpaceEdit constructor and destructor in .cxx to allow compile with debug on wntmsci12. 2009-08-12 Henning Brinkmann Added some SW_DLLPUBLIC to make compilable on wntmsci12. 2009-08-11 Henning Brinkmann #i102420# dbg_out: surround output for SwNodes with <nodes-array>. 2009-08-10 Henning Brinkmann #i102420# rewritten debug output for SwNodes. 2009-08-07 Henning Brinkmann #i102420# debug _MoveNodes: output the destination, too. Break after two iterations. 2009-08-07 Henning Brinkmann #i102420# _MoveNodes: Additionally check if destination index is inside source => false Check if current range was already handled => loop Debug output current range 2009-08-06 Henning Brinkmann merged DEV300_m54 2009-08-06 Henning Brinkmann added master fix 2009-08-06 Henning Brinkmann debug output for SwNodeRange 2009-08-04 Henning Brinkmann #i102844# robustness: check for NULL pointer to prevent crash 2009-08-03 Henning Brinkmann #i103475# applied patch and verified 2009-08-03 Henning Brinkmann Removed code preventing build of sw with DEBUG. 2009-09-11 convert-repo update tags 2009-09-10 kz CWS-TOOLING: integrate CWS os2port06dev300 2009-09-05 22:49:00 +0200 ydario r275858 : #i99588# applied os2port06 diff to DEV300 tree. 2009-09-10 kz CWS-TOOLING: integrate CWS mingwport23 2009-08-29 07:07:53 +0200 tono r275555 : i#104522: mingw port graphite 2009-08-29 07:07:26 +0200 tono r275554 : i#104522: mingw port printf format fix 2009-09-10 kz CWS-TOOLING: integrate CWS mh232 2009-08-26 03:52:57 +0200 mh r275385 : #i102182# FreeBSD patch 2009-08-26 03:43:20 +0200 mh r275384 : #i101333# patch for FreeBSD 2009-08-26 03:11:20 +0200 mh r275383 : #i39230 2009-08-26 03:07:51 +0200 mh r275382 : #i39230# more space for initials field 2009-08-26 02:41:19 +0200 mh r275380 : #i39230# use vos::osecurity for reading the user name 2009-08-18 22:06:00 +0200 mh r275130 : #i104243#, line ending problem with newer perl 2009-08-18 21:53:21 +0200 mh r275129 : #i39230# read initials via getpwnam 2009-08-18 21:34:05 +0200 mh r275128 : enable CAIROCANVAS for Linux and Mac, #i88613# 2009-08-17 18:02:59 +0200 mh r275067 : #i95498# make compile with gcc3 2009-09-10 kz CWS-TOOLING: integrate CWS tkr24 2009-09-07 14:31:06 +0200 is r275898 : #160081# adding NO_LICENSE_INTO_COPYRIGHT 2009-09-10 releng #i10000# change KeyMapping to SingletonRef<framework::KeyMapping> 2009-09-11 convert-repo update tags 2009-09-10 kz CWS-TOOLING: integrate CWS os2port06dev300 2009-09-05 22:49:00 +0200 ydario r275858 : #i99588# applied os2port06 diff to DEV300 tree. 2009-09-10 kz CWS-TOOLING: integrate CWS mingwport23 2009-08-29 07:07:53 +0200 tono r275555 : i#104522: mingw port graphite 2009-08-29 07:07:26 +0200 tono r275554 : i#104522: mingw port printf format fix 2009-09-10 kz CWS-TOOLING: integrate CWS mh232 2009-08-26 03:52:57 +0200 mh r275385 : #i102182# FreeBSD patch 2009-08-26 03:43:20 +0200 mh r275384 : #i101333# patch for FreeBSD 2009-08-26 03:11:20 +0200 mh r275383 : #i39230 2009-08-26 03:07:51 +0200 mh r275382 : #i39230# more space for initials field 2009-08-26 02:41:19 +0200 mh r275380 : #i39230# use vos::osecurity for reading the user name 2009-08-18 22:06:00 +0200 mh r275130 : #i104243#, line ending problem with newer perl 2009-08-18 21:53:21 +0200 mh r275129 : #i39230# read initials via getpwnam 2009-08-18 21:34:05 +0200 mh r275128 : enable CAIROCANVAS for Linux and Mac, #i88613# 2009-08-17 18:02:59 +0200 mh r275067 : #i95498# make compile with gcc3 2009-09-10 kz CWS-TOOLING: integrate CWS tkr24 2009-09-07 14:31:06 +0200 is r275898 : #160081# adding NO_LICENSE_INTO_COPYRIGHT 2009-09-10 releng #i10000# change KeyMapping to SingletonRef<framework::KeyMapping>
Diffstat (limited to 'sw/source/core/unocore')
-rw-r--r--sw/source/core/unocore/unobkm.cxx19
-rw-r--r--sw/source/core/unocore/unocoll.cxx11
-rw-r--r--sw/source/core/unocore/unocrsrhelper.cxx44
-rw-r--r--sw/source/core/unocore/unodraw.cxx39
-rw-r--r--sw/source/core/unocore/unofield.cxx69
-rw-r--r--sw/source/core/unocore/unoflatpara.cxx2
-rw-r--r--sw/source/core/unocore/unoframe.cxx2
-rw-r--r--sw/source/core/unocore/unoftn.cxx15
-rw-r--r--sw/source/core/unocore/unoidx.cxx36
-rw-r--r--sw/source/core/unocore/unomap.cxx20
-rw-r--r--sw/source/core/unocore/unoobj.cxx250
-rw-r--r--sw/source/core/unocore/unoobj2.cxx339
-rw-r--r--sw/source/core/unocore/unoparagraph.cxx1
-rw-r--r--sw/source/core/unocore/unoport.cxx464
-rw-r--r--sw/source/core/unocore/unoportenum.cxx1082
-rw-r--r--sw/source/core/unocore/unoprnms.cxx3
-rw-r--r--sw/source/core/unocore/unoredline.cxx4
-rw-r--r--sw/source/core/unocore/unorefmk.cxx1078
-rw-r--r--sw/source/core/unocore/unosect.cxx2
-rw-r--r--sw/source/core/unocore/unotext.cxx117
20 files changed, 2578 insertions, 1019 deletions
diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx
index a922c5334f3e..0a9528823689 100644
--- a/sw/source/core/unocore/unobkm.cxx
+++ b/sw/source/core/unocore/unobkm.cxx
@@ -46,6 +46,8 @@
#include <comcore.hrc>
#endif
#include <undobj.hxx>
+#include <docsh.hxx>
+
using namespace ::com::sun::star;
using namespace ::com::sun::star::lang;
@@ -280,6 +282,23 @@ void SwXBookmark::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew)
}
}
+// MetadatableMixin
+::sfx2::Metadatable* SwXBookmark::GetCoreObject()
+{
+ return dynamic_cast< ::sfx2::Metadatable* >( GetBookmark() );
+}
+
+uno::Reference<frame::XModel> SwXBookmark::GetModel()
+{
+ if (GetDoc())
+ {
+ SwDocShell const * const pShell( GetDoc()->GetDocShell() );
+ return (pShell) ? pShell->GetModel() : 0;
+ }
+ return 0;
+}
+
+
uno::Reference< beans::XPropertySetInfo > SwXBookmark::getPropertySetInfo(void)
throw( uno::RuntimeException )
{
diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx
index 4890f8c62920..7743ea61e43d 100644
--- a/sw/source/core/unocore/unocoll.cxx
+++ b/sw/source/core/unocore/unocoll.cxx
@@ -76,8 +76,10 @@
#include <slist>
#include <iterator>
+#include "unometa.hxx"
#include "docsh.hxx"
+
using ::rtl::OUString;
using namespace ::com::sun::star;
using namespace ::com::sun::star::document;
@@ -174,11 +176,11 @@ const ProvNamesId_Type __FAR_DATA aProvNamesId[] =
{ "com.sun.star.text.TextField.Bibliography", SW_SERVICE_FIELDTYPE_BIBLIOGRAPHY },
{ "com.sun.star.text.TextField.CombinedCharacters", SW_SERVICE_FIELDTYPE_COMBINED_CHARACTERS },
{ "com.sun.star.text.TextField.DropDown", SW_SERVICE_FIELDTYPE_DROPDOWN },
+ { "com.sun.star.text.textfield.MetadataField", SW_SERVICE_FIELDTYPE_METAFIELD },
{ "", SW_SERVICE_FIELDTYPE_DUMMY_4 },
{ "", SW_SERVICE_FIELDTYPE_DUMMY_5 },
{ "", SW_SERVICE_FIELDTYPE_DUMMY_6 },
{ "", SW_SERVICE_FIELDTYPE_DUMMY_7 },
- { "", SW_SERVICE_FIELDTYPE_DUMMY_8 },
{ "com.sun.star.text.FieldMaster.User", SW_SERVICE_FIELDMASTER_USER },
{ "com.sun.star.text.FieldMaster.DDE", SW_SERVICE_FIELDMASTER_DDE },
{ "com.sun.star.text.FieldMaster.SetExpression", SW_SERVICE_FIELDMASTER_SET_EXP },
@@ -207,6 +209,7 @@ const ProvNamesId_Type __FAR_DATA aProvNamesId[] =
{ "com.sun.star.chart2.data.DataProvider", SW_SERVICE_CHART2_DATA_PROVIDER },
{ "com.sun.star.text.Fieldmark", SW_SERVICE_TYPE_FIELDMARK },
{ "com.sun.star.text.FormFieldmark", SW_SERVICE_TYPE_FORMFIELDMARK },
+ { "com.sun.star.text.InContentMetadata", SW_SERVICE_TYPE_META },
// case-correct versions of the service names (see #i67811)
{ CSS_TEXT_TEXTFIELD_DATE_TIME, SW_SERVICE_FIELDTYPE_DATETIME },
@@ -604,6 +607,12 @@ uno::Reference< uno::XInterface > SwXServiceProvider::MakeInstance(sal_uInt16
if( pDoc->GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED )
xRet = (cppu::OWeakObject*) pDoc->GetChartDataProvider( true /* create - if not yet available */ );
break;
+ case SW_SERVICE_TYPE_META:
+ xRet = static_cast< ::cppu::OWeakObject* >( new SwXMeta(pDoc) );
+ break;
+ case SW_SERVICE_FIELDTYPE_METAFIELD:
+ xRet = static_cast< ::cppu::OWeakObject* >(new SwXMetaField(pDoc));
+ break;
default:
throw uno::RuntimeException();
}
diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx
index 0db5039f6a31..8c84dce7948a 100644
--- a/sw/source/core/unocore/unocrsrhelper.cxx
+++ b/sw/source/core/unocore/unocrsrhelper.cxx
@@ -343,20 +343,9 @@ sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry
{
if( pAny )
{
- const SwFmtFld& rFld = pTxtAttr->GetFld();
- SwClientIter aIter(*rFld.GetFld()->GetTyp());
- SwXTextField* pFld = 0;
- SwXTextField* pTemp = (SwXTextField*)aIter.First(TYPE(SwXTextField));
- while(pTemp && !pFld)
- {
- if(pTemp->GetFldFmt() == &rFld)
- pFld = pTemp;
- pTemp = (SwXTextField*)aIter.Next();
- }
- if(!pFld)
- pFld = new SwXTextField( rFld, rPam.GetDoc());
- uno::Reference< XTextField > xRet = pFld;
- pAny->setValue(&xRet, ::getCppuType((uno::Reference<XTextField>*)0));
+ SwXTextField* pField = CreateSwXTextField(*rPam.GetDoc(),
+ pTxtAttr->GetFld());
+ *pAny <<= uno::Reference< XTextField >( pField );
}
}
else
@@ -943,25 +932,37 @@ void InsertFile(SwUnoCrsr* pUnoCrsr,
// paragraph breaks at those positions by calling SplitNode
sal_Bool DocInsertStringSplitCR(
SwDoc &rDoc,
- const SwPaM &rNewCursor, const String &rText )
+ const SwPaM &rNewCursor, const String &rText,
+ const bool bForceExpandHints )
{
sal_Bool bOK = sal_True;
+ const enum IDocumentContentOperations::InsertFlags nInsertFlags =
+ (bForceExpandHints)
+ ? static_cast<IDocumentContentOperations::InsertFlags>(
+ IDocumentContentOperations::INS_FORCEHINTEXPAND |
+ IDocumentContentOperations::INS_EMPTYEXPAND)
+ : IDocumentContentOperations::INS_EMPTYEXPAND;
+
OUString aTxt;
xub_StrLen nStartIdx = 0;
- xub_StrLen nMaxLength = STRING_LEN;
- SwTxtNode* pTxtNd = rNewCursor.GetPoint()->nNode.GetNode().GetTxtNode();
- if( pTxtNd )
- nMaxLength = STRING_LEN - pTxtNd->GetTxt().Len();
+ SwTxtNode* const pTxtNd =
+ rNewCursor.GetPoint()->nNode.GetNode().GetTxtNode();
+ const xub_StrLen nMaxLength = ( pTxtNd )
+ ? STRING_LEN - pTxtNd->GetTxt().Len()
+ : STRING_LEN;
xub_StrLen nIdx = rText.Search( '\r', nStartIdx );
if( ( nIdx == STRING_NOTFOUND && nMaxLength < rText.Len() ) ||
( nIdx != STRING_NOTFOUND && nMaxLength < nIdx ) )
+ {
nIdx = nMaxLength;
+ }
while (nIdx != STRING_NOTFOUND )
{
DBG_ASSERT( nIdx - nStartIdx >= 0, "index negative!" );
aTxt = rText.Copy( nStartIdx, nIdx - nStartIdx );
- if (aTxt.getLength() && !rDoc.Insert( rNewCursor, aTxt, true ))
+ if (aTxt.getLength() &&
+ !rDoc.InsertString( rNewCursor, aTxt, nInsertFlags ))
{
DBG_ERROR( "Doc->Insert(Str) failed." );
bOK = sal_False;
@@ -975,7 +976,8 @@ sal_Bool DocInsertStringSplitCR(
nIdx = rText.Search( '\r', nStartIdx );
}
aTxt = rText.Copy( nStartIdx );
- if (aTxt.getLength() && !rDoc.Insert( rNewCursor, aTxt, true ))
+ if (aTxt.getLength() &&
+ !rDoc.InsertString( rNewCursor, aTxt, nInsertFlags ))
{
DBG_ERROR( "Doc->Insert(Str) failed." );
bOK = sal_False;
diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx
index 1989c74df6ed..11b3eae5a16a 100644
--- a/sw/source/core/unocore/unodraw.cxx
+++ b/sw/source/core/unocore/unodraw.cxx
@@ -1297,20 +1297,25 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A
SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode();
ASSERT( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." );
const xub_StrLen nIdx = pPos->nContent.GetIndex();
- SwTxtAttr * pHnt = pTxtNode->GetTxtAttr( nIdx, RES_TXTATR_FLYCNT );
+ SwTxtAttr * const pHnt =
+ pTxtNode->GetTxtAttrForCharAt(
+ nIdx, RES_TXTATR_FLYCNT );
DBG_ASSERT( pHnt && pHnt->Which() == RES_TXTATR_FLYCNT,
"Missing FlyInCnt-Hint." );
DBG_ASSERT( pHnt && pHnt->GetFlyCnt().GetFrmFmt() == pFmt,
"Wrong TxtFlyCnt-Hint." );
- ((SwFmtFlyCnt&)pHnt->GetFlyCnt()).SetFlyFmt();
+ const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt())
+ .SetFlyFmt();
//The connection is removed now the attribute can be deleted.
- pTxtNode->Delete( RES_TXTATR_FLYCNT, nIdx, nIdx );
+ pTxtNode->DeleteAttributes(
+ RES_TXTATR_FLYCNT, nIdx );
//create a new one
SwTxtNode *pNd = pInternalPam->GetNode()->GetTxtNode();
- DBG_ASSERT( pNd, "Crsr steht nicht auf TxtNode." );
- pNd->InsertItem( SwFmtFlyCnt( pFmt ),
- pInternalPam->GetPoint()->nContent.GetIndex(), 0 );
+ DBG_ASSERT( pNd, "Cursor not at TxtNode." );
+ SwFmtFlyCnt aFmt( pFmt );
+ pNd->InsertItem(aFmt, pInternalPam->GetPoint()
+ ->nContent.GetIndex(), 0 );
}
else
{
@@ -1379,15 +1384,18 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A
SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode();
ASSERT( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." );
const xub_StrLen nIdx = pPos->nContent.GetIndex();
- SwTxtAttr * pHnt = pTxtNode->GetTxtAttr( nIdx, RES_TXTATR_FLYCNT );
+ SwTxtAttr * const pHnt =
+ pTxtNode->GetTxtAttrForCharAt(
+ nIdx, RES_TXTATR_FLYCNT );
DBG_ASSERT( pHnt && pHnt->Which() == RES_TXTATR_FLYCNT,
"Missing FlyInCnt-Hint." );
DBG_ASSERT( pHnt && pHnt->GetFlyCnt().GetFrmFmt() == pFlyFmt,
"Wrong TxtFlyCnt-Hint." );
- ((SwFmtFlyCnt&)pHnt->GetFlyCnt()).SetFlyFmt();
+ const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt())
+ .SetFlyFmt();
//The connection is removed now the attribute can be deleted.
- pTxtNode->Delete( RES_TXTATR_FLYCNT, nIdx, nIdx );
+ pTxtNode->DeleteAttributes(RES_TXTATR_FLYCNT, nIdx);
}
else if( text::TextContentAnchorType_AT_PAGE != eNewAnchor &&
FLY_PAGE == eOldAnchorId )
@@ -1418,8 +1426,9 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A
//the RES_TXTATR_FLYCNT needs to be added now
SwTxtNode *pNd = aPam.GetNode()->GetTxtNode();
DBG_ASSERT( pNd, "Crsr is not in a TxtNode." );
- pNd->InsertItem( SwFmtFlyCnt( pFlyFmt ),
- aPam.GetPoint()->nContent.GetIndex(), 0 );
+ SwFmtFlyCnt aFmt( pFlyFmt );
+ pNd->InsertItem(aFmt,
+ aPam.GetPoint()->nContent.GetIndex(), 0 );
//aPam.GetPoint()->nContent--;
}
@@ -2124,8 +2133,10 @@ void SwXShape::attach(const uno::Reference< text::XTextRange > & xTextRange)
pDoc = pText->GetDoc();
else if (!pDoc && pCursor)
pDoc = pCursor->GetDoc();
- else if ( !pDoc && pPortion && pPortion->GetCrsr() )
- pDoc = pPortion->GetCrsr()->GetDoc();
+ else if ( !pDoc && pPortion && pPortion->GetCursor() )
+ {
+ pDoc = pPortion->GetCursor()->GetDoc();
+ }
}
@@ -2213,7 +2224,7 @@ void SwXShape::dispose(void) throw( uno::RuntimeException )
const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor());
SwTxtNode *pTxtNode = rPos.nNode.GetNode().GetTxtNode();
const xub_StrLen nIdx = rPos.nContent.GetIndex();
- pTxtNode->Delete( RES_TXTATR_FLYCNT, nIdx, nIdx );
+ pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx );
}
else
pFmt->GetDoc()->DelLayoutFmt( pFmt );
diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx
index 1a14b5441eb6..f8de0eb39691 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -94,6 +94,7 @@
#include <textapi.hxx>
#include <svx/outliner.hxx>
#include <docsh.hxx>
+#include <fmtmeta.hxx> // MetaFieldManager
using ::rtl::OUString;
using namespace ::com::sun::star;
@@ -371,7 +372,7 @@ USHORT lcl_GetPropertyMapOfService( USHORT nServiceId )
case SW_SERVICE_FIELDTYPE_DUMMY_5:
case SW_SERVICE_FIELDTYPE_DUMMY_6:
case SW_SERVICE_FIELDTYPE_DUMMY_7:
- case SW_SERVICE_FIELDTYPE_DUMMY_8: nRet = PROPERTY_MAP_FLDTYP_DUMMY_0; break;
+ nRet = PROPERTY_MAP_FLDTYP_DUMMY_0; break;
case SW_SERVICE_FIELDMASTER_USER: nRet = PROPERTY_MAP_FLDMSTR_USER; break;
case SW_SERVICE_FIELDMASTER_DDE: nRet = PROPERTY_MAP_FLDMSTR_DDE; break;
case SW_SERVICE_FIELDMASTER_SET_EXP: nRet = PROPERTY_MAP_FLDMSTR_SET_EXP; break;
@@ -784,24 +785,12 @@ uno::Any SwXFieldMaster::getPropertyValue(const OUString& rPropertyName)
}
uno::Sequence<uno::Reference <text::XDependentTextField> > aRetSeq(aFldArr.Count());
uno::Reference<text::XDependentTextField>* pRetSeq = aRetSeq.getArray();
- SwXTextField* pInsert = 0;
for(USHORT i = 0; i < aFldArr.Count(); i++)
{
pFld = aFldArr.GetObject(i);
- SwXTextField* pTemp = (SwXTextField*)aIter.First(TYPE(SwXTextField));
- while(pTemp)
- {
- if(pTemp->GetFldFmt() == pFld)
- {
- pInsert = pTemp;
- break;
- }
- pTemp = (SwXTextField*)aIter.Next();
- }
- if(!pInsert)
- pInsert = new SwXTextField( *pFld, GetDoc());
+ SwXTextField * pInsert = CreateSwXTextField(*GetDoc(), *pFld);
+
pRetSeq[i] = uno::Reference<text::XDependentTextField>(pInsert);
- pInsert = 0;
}
aRet <<= aRetSeq;
}
@@ -1079,6 +1068,26 @@ OUString SwXFieldMaster::LocalizeFormula(
}
return rFormula;
}
+
+
+SwXTextField * CreateSwXTextField(SwDoc & rDoc, SwFmtFld const& rFmt)
+{
+ SwClientIter aIter(*rFmt.GetFld()->GetTyp());
+ SwXTextField * pField = 0;
+ SwXTextField * pTemp =
+ static_cast<SwXTextField*>(aIter.First( TYPE(SwXTextField) ));
+ while (pTemp)
+ {
+ if (pTemp->GetFldFmt() == &rFmt)
+ {
+ pField = pTemp;
+ break;
+ }
+ pTemp = static_cast<SwXTextField*>(aIter.Next());
+ }
+ return pField ? pField : new SwXTextField( rFmt, &rDoc );
+}
+
/******************************************************************
*
******************************************************************/
@@ -1809,8 +1818,18 @@ void SwXTextField::attachToRange(
SwTxtAttr* pTxtAttr = 0;
if(aPam.HasMark())
pDoc->DeleteAndJoin(aPam);
- pDoc->Insert(aPam, aFmt, 10000);
- pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttr(
+
+ SwXTextCursor const*const pTextCursor(
+ dynamic_cast<SwXTextCursor*>(pCursor));
+ const bool bForceExpandHints( (pTextCursor)
+ ? pTextCursor->IsAtEndOfMeta() : false );
+ const SetAttrMode nInsertFlags = (bForceExpandHints)
+ ? nsSetAttrMode::SETATTR_FORCEHINTEXPAND
+ : nsSetAttrMode::SETATTR_DEFAULT;
+
+ pDoc->InsertPoolItem(aPam, aFmt, nInsertFlags);
+
+ pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt(
aPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_FIELD);
// was passiert mit dem Update der Felder ? (siehe fldmgr.cxx)
@@ -2915,6 +2934,22 @@ SwXFieldEnumeration::SwXFieldEnumeration(SwDoc* pDc) :
}
}
}
+ // now handle meta-fields, which are not SwFields
+ const ::std::vector< uno::Reference<text::XTextField> > MetaFields(
+ pDc->GetMetaFieldManager().getMetaFields() );
+ for (size_t i = 0; i < MetaFields.size(); ++i)
+ {
+ pItems[ nFillPos ] = MetaFields[i];
+ nFillPos++;
+
+ //FIXME UGLY
+ // enlarge sequence if necessary
+ if (aItems.getLength() == nFillPos)
+ {
+ aItems.realloc( 2 * aItems.getLength() );
+ pItems = aItems.getArray();
+ }
+ }
// resize sequence to actual used size
aItems.realloc( nFillPos );
}
diff --git a/sw/source/core/unocore/unoflatpara.cxx b/sw/source/core/unocore/unoflatpara.cxx
index fcfb8eb135fd..ae773f389f30 100644
--- a/sw/source/core/unocore/unoflatpara.cxx
+++ b/sw/source/core/unocore/unoflatpara.cxx
@@ -228,7 +228,7 @@ void SAL_CALL SwXFlatParagraph::changeText(::sal_Int32 nPos, ::sal_Int32 nLen, c
mpTxtNode = pOldTxtNode; // setPropertyValue() modifies this. We restore the old state.
IDocumentContentOperations* pIDCO = mpTxtNode->getIDocumentContentOperations();
- pIDCO->Replace( aPaM, aNewText, false );
+ pIDCO->ReplaceRange( aPaM, aNewText, false );
mpTxtNode = 0;
}
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index 7237cb59ed02..09066c447546 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -2028,7 +2028,7 @@ void SwXFrame::dispose(void) throw( uno::RuntimeException )
const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor());
SwTxtNode *pTxtNode = rPos.nNode.GetNode().GetTxtNode();
const xub_StrLen nIdx = rPos.nContent.GetIndex();
- pTxtNode->Delete( RES_TXTATR_FLYCNT, nIdx, nIdx );
+ pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx, nIdx );
}
else
pFmt->GetDoc()->DelLayoutFmt(pFmt);
diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx
index aea52396f366..98ee87c2ae33 100644
--- a/sw/source/core/unocore/unoftn.cxx
+++ b/sw/source/core/unocore/unoftn.cxx
@@ -254,11 +254,18 @@ void SwXFootnote::attachToRange(const uno::Reference< text::XTextRange > & xText
SwFmtFtn aFootNote(m_bIsEndnote);
if(m_sLabel.Len())
aFootNote.SetNumStr(m_sLabel);
- SfxItemSet aSet(pNewDoc->GetAttrPool(), RES_TXTATR_FTN, RES_TXTATR_FTN, 0L);
- aSet.Put(aFootNote);
- SwXTextCursor::SetCrsrAttr(aPam, aSet, 0);
- pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttr(
+ SwXTextCursor const*const pTextCursor(
+ dynamic_cast<SwXTextCursor*>(pCursor));
+ const bool bForceExpandHints( (pTextCursor)
+ ? pTextCursor->IsAtEndOfMeta() : false );
+ const SetAttrMode nInsertFlags = (bForceExpandHints)
+ ? nsSetAttrMode::SETATTR_FORCEHINTEXPAND
+ : nsSetAttrMode::SETATTR_DEFAULT;
+
+ pNewDoc->InsertPoolItem(aPam, aFootNote, nInsertFlags);
+
+ pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt(
aPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_FTN );
if(pTxtAttr)
diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx
index 5fbec1e277a1..5633ca1f0661 100644
--- a/sw/source/core/unocore/unoidx.cxx
+++ b/sw/source/core/unocore/unoidx.cxx
@@ -1369,7 +1369,7 @@ void SwXDocumentIndexMark::setMarkEntry(const OUString& rIndexEntry) throw( uno:
aPam.GetPoint()->nContent++;
//die alte Marke loeschen
- m_pDoc->Delete(m_pTOXMark);
+ m_pDoc->DeleteTOXMark(m_pTOXMark);
m_pTOXMark = 0;
SwTxtAttr* pTxtAttr = 0;
@@ -1379,13 +1379,14 @@ void SwXDocumentIndexMark::setMarkEntry(const OUString& rIndexEntry) throw( uno:
if( bInsAtPos )
{
SwPaM aTmp( *pStt );
- m_pDoc->Insert( aTmp, aMark, 0 );
- pTxtAttr = pStt->nNode.GetNode().GetTxtNode()->GetTxtAttr(
+ m_pDoc->InsertPoolItem( aTmp, aMark, 0 );
+ pTxtAttr = pStt->nNode.GetNode().GetTxtNode()->GetTxtAttrForCharAt(
pStt->nContent.GetIndex()-1, RES_TXTATR_TOXMARK);
}
else if( *pEnd != *pStt )
{
- m_pDoc->Insert( aPam, aMark, nsSetAttrMode::SETATTR_DONTEXPAND );
+ m_pDoc->InsertPoolItem( aPam, aMark,
+ nsSetAttrMode::SETATTR_DONTEXPAND );
pTxtAttr = pStt->nNode.GetNode().GetTxtNode()->GetTxtAttr(
pStt->nContent, RES_TXTATR_TOXMARK);
}
@@ -1501,7 +1502,17 @@ void SwXDocumentIndexMark::attachToRange(const uno::Reference< text::XTextRange
// deshalb hier ein Leerzeichen - ob das die ideale Loesung ist?
if(!bMark && !aMark.GetAlternativeText().Len())
aMark.SetAlternativeText( String(' ') );
- pDoc->Insert(aPam, aMark, nsSetAttrMode::SETATTR_DONTEXPAND);
+
+ SwXTextCursor const*const pTextCursor(
+ dynamic_cast<SwXTextCursor*>(pCursor));
+ const bool bForceExpandHints( (!bMark && pTextCursor)
+ ? pTextCursor->IsAtEndOfMeta() : false );
+ const SetAttrMode nInsertFlags = (bForceExpandHints)
+ ? ( nsSetAttrMode::SETATTR_FORCEHINTEXPAND
+ | nsSetAttrMode::SETATTR_DONTEXPAND)
+ : nsSetAttrMode::SETATTR_DONTEXPAND;
+
+ pDoc->InsertPoolItem(aPam, aMark, nInsertFlags);
if( bMark && *aPam.GetPoint() > *aPam.GetMark())
aPam.Exchange();
@@ -1510,8 +1521,10 @@ void SwXDocumentIndexMark::attachToRange(const uno::Reference< text::XTextRange
pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttr(
aPam.GetPoint()->nContent, RES_TXTATR_TOXMARK );
else
- pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttr(
+ {
+ pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt(
aPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_TOXMARK );
+ }
if(pTxtAttr)
{
@@ -1571,7 +1584,7 @@ void SwXDocumentIndexMark::dispose(void) throw( uno::RuntimeException )
SwTOXType* pType = ((SwXDocumentIndexMark*)this)->GetTOXType();
if(pType && m_pTOXMark)
{
- m_pDoc->Delete(m_pTOXMark);
+ m_pDoc->DeleteTOXMark(m_pTOXMark);
}
else
throw uno::RuntimeException();
@@ -1681,7 +1694,7 @@ void SwXDocumentIndexMark::setPropertyValue(const OUString& rPropertyName,
aPam.GetPoint()->nContent++;
//delete the old mark
- pLocalDoc->Delete(m_pTOXMark);
+ pLocalDoc->DeleteTOXMark(m_pTOXMark);
m_pTOXMark = 0;
sal_Bool bInsAtPos = aMark.IsAlternativeText();
@@ -1692,13 +1705,14 @@ void SwXDocumentIndexMark::setPropertyValue(const OUString& rPropertyName,
if( bInsAtPos )
{
SwPaM aTmp( *pStt );
- pLocalDoc->Insert( aTmp, aMark, 0 );
- pTxtAttr = pStt->nNode.GetNode().GetTxtNode()->GetTxtAttr(
+ pLocalDoc->InsertPoolItem( aTmp, aMark, 0 );
+ pTxtAttr = pStt->nNode.GetNode().GetTxtNode()->GetTxtAttrForCharAt(
pStt->nContent.GetIndex()-1, RES_TXTATR_TOXMARK );
}
else if( *pEnd != *pStt )
{
- pLocalDoc->Insert( aPam, aMark, nsSetAttrMode::SETATTR_DONTEXPAND );
+ pLocalDoc->InsertPoolItem( aPam, aMark,
+ nsSetAttrMode::SETATTR_DONTEXPAND );
pTxtAttr = pStt->nNode.GetNode().GetTxtNode()->GetTxtAttr(
pStt->nContent, RES_TXTATR_TOXMARK );
}
diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx
index 3730da041f90..f2f48e382508 100644
--- a/sw/source/core/unocore/unomap.cxx
+++ b/sw/source/core/unocore/unomap.cxx
@@ -1649,6 +1649,7 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s
{SW_PROP_NMID(UNO_NAME_IS_START), FN_UNO_IS_START, CPPU_E2T(CPPUTYPE_BOOLEAN), PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY, 0 },
//_REDLINE_PROPERTIES
{SW_PROP_NMID(UNO_NAME_TEXT_PORTION_TYPE), FN_UNO_TEXT_PORTION_TYPE, CPPU_E2T(CPPUTYPE_OUSTRING), PropertyAttribute::READONLY, 0},
+ {SW_PROP_NMID(UNO_NAME_META), FN_UNO_META, CPPU_E2T(CPPUTYPE_REFTEXTCNTNT), PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY, 0 },
{0,0,0,0,0,0}
};
aMapEntriesArr[nPropertyId] = aTextPortionExtensionMap_Impl;
@@ -2484,6 +2485,19 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s
aMapEntriesArr[nPropertyId] = aChart2DataSequenceMap;
}
break;
+ case PROPERTY_MAP_METAFIELD:
+ {
+ static SfxItemPropertyMapEntry aMetaFieldMap[] =
+ {
+ { SW_PROP_NMID(UNO_NAME_NUMBER_FORMAT), 0,
+ CPPU_E2T(CPPUTYPE_INT32), PROPERTY_NONE, 0 },
+ { SW_PROP_NMID(UNO_NAME_IS_FIXED_LANGUAGE), 0,
+ CPPU_E2T(CPPUTYPE_BOOLEAN), PROPERTY_NONE, 0 },
+ {0,0,0,0,0,0}
+ };
+ aMapEntriesArr[nPropertyId] = aMetaFieldMap;
+ }
+ break;
default:
DBG_ERROR( "unexpected property map ID" );
@@ -3091,6 +3105,12 @@ const SfxItemPropertySet* SwUnoPropertyMapProvider::GetPropertySet( sal_uInt16
aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_DOCINFO_CUSTOM;
}
break;
+ case PROPERTY_MAP_METAFIELD:
+ {
+ static SfxItemPropertySet aPROPERTY_MAP_METAFIELD(pEntries);
+ aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_METAFIELD;
+ }
+ break;
}
}
return aPropertySetArr[nPropertyId];
diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx
index 9b2bebb67977..70d9560eef17 100644
--- a/sw/source/core/unocore/unoobj.cxx
+++ b/sw/source/core/unocore/unoobj.cxx
@@ -59,7 +59,6 @@
#include <swerror.h>
#include <swtblfmt.hxx>
#include <fmtruby.hxx>
-#include <fmthbsh.hxx>
#include <docsh.hxx>
#include <docstyle.hxx>
#include <charfmt.hxx>
@@ -92,6 +91,7 @@
#include <unocoll.hxx>
#include <unostyle.hxx>
#include <unofield.hxx>
+#include <unometa.hxx>
#include <fmtanchr.hxx>
#include <svx/flstitem.hxx>
#include <svtools/ctrltool.hxx>
@@ -118,11 +118,10 @@
#include <dcontact.hxx>
#include <SwStyleNameMapper.hxx>
#include <crsskip.hxx>
-#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPPP_
#include <com/sun/star/beans/PropertyAttribute.hpp>
-#endif
#include <memory>
+
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
@@ -378,9 +377,11 @@ void lcl_SetTxtFmtColl(const uno::Any& rAny, SwPaM& rPaM)
SwTxtFmtColl *pLocal = pStyle->GetCollection();
UnoActionContext aAction(pDoc);
pDoc->StartUndo( UNDO_START, NULL );
- FOREACHUNOPAM_START(&rPaM)
- pDoc->SetTxtFmtColl(*PUNOPAM, pLocal);
- FOREACHUNOPAM_END()
+ SwPaM *pTmpCrsr = &rPaM;
+ do {
+ pDoc->SetTxtFmtColl(*pTmpCrsr, pLocal);
+ pTmpCrsr = static_cast<SwPaM*>(pTmpCrsr->GetNext());
+ } while ( pTmpCrsr != &rPaM );
pDoc->EndUndo( UNDO_END, NULL );
}
else
@@ -653,7 +654,7 @@ return bRet;
/* -----------------30.06.98 08:39-------------------
*
* --------------------------------------------------*/
-SwFmtColl* SwXTextCursor::GetCurTxtFmtColl(SwPaM& rPam, BOOL bConditional)
+SwFmtColl* SwXTextCursor::GetCurTxtFmtColl(SwPaM& rPaM, BOOL bConditional)
{
static const sal_uInt16 nMaxLookup = 1000;
SwFmtColl *pFmt = 0;
@@ -661,12 +662,13 @@ SwFmtColl* SwXTextCursor::GetCurTxtFmtColl(SwPaM& rPam, BOOL bConditional)
// if ( GetCrsrCnt() > nMaxLookup )
// return 0;
sal_Bool bError = sal_False;
- FOREACHUNOPAM_START(&rPam)
+ SwPaM *pTmpCrsr = &rPaM;
+ do {
- ULONG nSttNd = PUNOPAM->GetMark()->nNode.GetIndex(),
- nEndNd = PUNOPAM->GetPoint()->nNode.GetIndex();
- xub_StrLen nSttCnt = PUNOPAM->GetMark()->nContent.GetIndex(),
- nEndCnt = PUNOPAM->GetPoint()->nContent.GetIndex();
+ ULONG nSttNd = pTmpCrsr->GetMark()->nNode.GetIndex();
+ ULONG nEndNd = pTmpCrsr->GetPoint()->nNode.GetIndex();
+ xub_StrLen nSttCnt = pTmpCrsr->GetMark()->nContent.GetIndex();
+ xub_StrLen nEndCnt = pTmpCrsr->GetPoint()->nContent.GetIndex();
if( nSttNd > nEndNd || ( nSttNd == nEndNd && nSttCnt > nEndCnt ))
{
@@ -680,7 +682,7 @@ SwFmtColl* SwXTextCursor::GetCurTxtFmtColl(SwPaM& rPam, BOOL bConditional)
break;
}
- const SwNodes& rNds = rPam.GetDoc()->GetNodes();
+ const SwNodes& rNds = rPaM.GetDoc()->GetNodes();
for( ULONG n = nSttNd; n <= nEndNd; ++n )
{
const SwTxtNode* pNd = rNds[ n ]->GetTxtNode();
@@ -699,7 +701,9 @@ SwFmtColl* SwXTextCursor::GetCurTxtFmtColl(SwPaM& rPam, BOOL bConditional)
}
if(bError)
break;
- FOREACHUNOPAM_END()
+
+ pTmpCrsr = static_cast<SwPaM*>(pTmpCrsr->GetNext());
+ } while ( pTmpCrsr != &rPaM );
return bError ? 0 : pFmt;
}
@@ -851,7 +855,8 @@ SwXTextCursor::~SwXTextCursor()
/*-- 09.12.98 14:19:18---------------------------------------------------
-----------------------------------------------------------------------*/
-void SwXTextCursor::DeleteAndInsert(const String& rText)
+void SwXTextCursor::DeleteAndInsert(const String& rText,
+ const bool bForceExpandHints)
{
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(pUnoCrsr)
@@ -870,10 +875,12 @@ void SwXTextCursor::DeleteAndInsert(const String& rText)
}
if(nTxtLen)
{
- if( !SwUnoCursorHelper::DocInsertStringSplitCR( *pDoc, *_pStartCrsr, rText ) )
- {
- DBG_ASSERT( sal_False, "Doc->Insert(Str) failed." );
- }
+ const bool bSuccess(
+ SwUnoCursorHelper::DocInsertStringSplitCR(
+ *pDoc, *_pStartCrsr, rText, bForceExpandHints ) );
+ DBG_ASSERT( bSuccess, "Doc->Insert(Str) failed." );
+ (void) bSuccess;
+
SwXTextCursor::SelectPam(*pUnoCrsr, sal_True);
_pStartCrsr->Left(rText.Len(), CRSR_SKIP_CHARS, FALSE, FALSE);
}
@@ -881,6 +888,82 @@ void SwXTextCursor::DeleteAndInsert(const String& rText)
pDoc->EndUndo(UNDO_INSERT, NULL);
}
}
+
+
+enum ForceIntoMetaMode { META_CHECK_BOTH, META_INIT_START, META_INIT_END };
+
+sal_Bool lcl_ForceIntoMeta(SwPaM & rCursor,
+ uno::Reference<text::XText> const & xParentText,
+ const enum ForceIntoMetaMode eMode)
+{
+ sal_Bool bRet( sal_True ); // means not forced in META_CHECK_BOTH
+ SwXMeta const * const pXMeta( dynamic_cast<SwXMeta*>(xParentText.get()) );
+ ASSERT(pXMeta, "no parent?");
+ if (!pXMeta)
+ throw uno::RuntimeException();
+ SwTxtNode * pTxtNode;
+ xub_StrLen nStart;
+ xub_StrLen nEnd;
+ const bool bSuccess( pXMeta->SetContentRange(pTxtNode, nStart, nEnd) );
+ ASSERT(bSuccess, "no pam?");
+ if (!bSuccess)
+ throw uno::RuntimeException();
+ // force the cursor back into the meta if it has moved outside
+ SwPosition start(*pTxtNode, nStart);
+ SwPosition end(*pTxtNode, nEnd);
+ switch (eMode)
+ {
+ case META_INIT_START:
+ *rCursor.GetPoint() = start;
+ break;
+ case META_INIT_END:
+ *rCursor.GetPoint() = end;
+ break;
+ case META_CHECK_BOTH:
+ if (*rCursor.Start() < start)
+ {
+ *rCursor.Start() = start;
+ bRet = sal_False;
+ }
+ if (*rCursor.End() > end)
+ {
+ *rCursor.End() = end;
+ bRet = sal_False;
+ }
+ break;
+ }
+ return bRet;
+}
+
+bool SwXTextCursor::IsAtEndOfMeta() const
+{
+ if (CURSOR_META == eType)
+ {
+ SwUnoCrsr const * const pCursor( GetCrsr() );
+ SwXMeta const*const pXMeta( dynamic_cast<SwXMeta*>(xParentText.get()) );
+ ASSERT(pXMeta, "no meta?");
+ if (pCursor && pXMeta)
+ {
+ SwTxtNode * pTxtNode;
+ xub_StrLen nStart;
+ xub_StrLen nEnd;
+ const bool bSuccess(
+ pXMeta->SetContentRange(pTxtNode, nStart, nEnd) );
+ ASSERT(bSuccess, "no pam?");
+ if (bSuccess)
+ {
+ const SwPosition end(*pTxtNode, nEnd);
+ if ( (*pCursor->GetPoint() == end)
+ || (*pCursor->GetMark() == end))
+ {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+
/* -----------------------------10.03.00 18:02--------------------------------
---------------------------------------------------------------------------*/
@@ -972,6 +1055,11 @@ sal_Bool SwXTextCursor::goLeft(sal_Int16 nCount, sal_Bool Expand) throw( uno::Ru
{
SwXTextCursor::SelectPam(*pUnoCrsr, Expand);
bRet = pUnoCrsr->Left( nCount, CRSR_SKIP_CHARS, FALSE, FALSE);
+ if (CURSOR_META == eType)
+ {
+ bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH)
+ && bRet;
+ }
}
else
{
@@ -991,6 +1079,11 @@ sal_Bool SwXTextCursor::goRight(sal_Int16 nCount, sal_Bool Expand) throw( uno::R
{
SwXTextCursor::SelectPam(*pUnoCrsr, Expand);
bRet = pUnoCrsr->Right(nCount, CRSR_SKIP_CHARS, FALSE, FALSE);
+ if (CURSOR_META == eType)
+ {
+ bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH)
+ && bRet;
+ }
}
else
{
@@ -1044,6 +1137,10 @@ void SwXTextCursor::gotoStart(sal_Bool Expand) throw( uno::RuntimeException )
{
pUnoCrsr->MoveSection( fnSectionCurr, fnSectionStart);
}
+ else if (CURSOR_META == eType)
+ {
+ lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_INIT_START);
+ }
}
else
{
@@ -1061,7 +1158,9 @@ void SwXTextCursor::gotoEnd(sal_Bool Expand) throw( uno::RuntimeException )
{
SwXTextCursor::SelectPam(*pUnoCrsr, Expand);
if(eType == CURSOR_BODY)
+ {
pUnoCrsr->Move( fnMoveForward, fnGoDoc );
+ }
else if(eType == CURSOR_FRAME ||
eType == CURSOR_TBLTEXT ||
eType == CURSOR_HEADER ||
@@ -1071,6 +1170,10 @@ void SwXTextCursor::gotoEnd(sal_Bool Expand) throw( uno::RuntimeException )
{
pUnoCrsr->MoveSection( fnSectionCurr, fnSectionEnd);
}
+ else if (CURSOR_META == eType)
+ {
+ lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_INIT_END);
+ }
}
else
{
@@ -1099,6 +1202,11 @@ void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_B
sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) ));
}
+ if (!pRange && !pCursor)
+ {
+ throw uno::RuntimeException();
+ }
+
SwStartNodeType eSearchNodeType = SwNormalStartNode;
switch(eType)
{
@@ -1141,6 +1249,27 @@ void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_B
throw uno::RuntimeException();
}
+ if (CURSOR_META == eType)
+ {
+ const SwPosition & rPoint( (pRange)
+ ? pRange->GetBookmark()->GetMarkPos()
+ : *pCursor->GetPaM()->GetPoint() );
+ const SwPosition & rMark ( (pRange)
+ ? ((pRange->GetBookmark()->IsExpanded())
+ ? pRange->GetBookmark()->GetOtherMarkPos() : rPoint)
+ : *pCursor->GetPaM()->GetMark() );
+ SwPaM aPam(rPoint, rMark);
+ const bool bNotForced(
+ lcl_ForceIntoMeta(aPam, xParentText, META_CHECK_BOTH) );
+ if (!bNotForced)
+ {
+ throw uno::RuntimeException(
+ C2U("gotoRange: parameter range not contained in nesting"
+ " text content for which this cursor was created"),
+ static_cast<text::XWordCursor*>(this));
+ }
+ }
+
//jetzt muss die Selektion erweitert werden
if(bExpand)
{
@@ -1277,7 +1406,9 @@ sal_Bool SwXTextCursor::gotoNextWord(sal_Bool Expand) throw( uno::RuntimeExcepti
//Absatzende?
if(pUnoCrsr->GetCntntNode() &&
pPoint->nContent == pUnoCrsr->GetCntntNode()->Len())
+ {
pUnoCrsr->Right(1, CRSR_SKIP_CHARS, FALSE, FALSE);
+ }
else
{
sal_Bool bTmp = pUnoCrsr->GoNextWordWT( i18n::WordType::DICTIONARY_WORD );
@@ -1289,6 +1420,10 @@ sal_Bool SwXTextCursor::gotoNextWord(sal_Bool Expand) throw( uno::RuntimeExcepti
// return true if cursor has moved
bRet = &pPoint->nNode.GetNode() != pOldNode ||
pPoint->nContent.GetIndex() != nOldIndex;
+ if (bRet && (CURSOR_META == eType))
+ {
+ bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH);
+ }
}
else
{
@@ -1316,7 +1451,9 @@ sal_Bool SwXTextCursor::gotoPreviousWord(sal_Bool Expand) throw( uno::RuntimeExc
SwXTextCursor::SelectPam(*pUnoCrsr, Expand);
//Absatzanfang ?
if(pPoint->nContent == 0)
+ {
pUnoCrsr->Left(1, CRSR_SKIP_CHARS, FALSE, FALSE);
+ }
else
{
pUnoCrsr->GoPrevWordWT( i18n::WordType::DICTIONARY_WORD );
@@ -1327,6 +1464,10 @@ sal_Bool SwXTextCursor::gotoPreviousWord(sal_Bool Expand) throw( uno::RuntimeExc
// return true if cursor has moved
bRet = &pPoint->nNode.GetNode() != pOldNode ||
pPoint->nContent.GetIndex() != nOldIndex;
+ if (bRet && (CURSOR_META == eType))
+ {
+ bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH);
+ }
}
else
{
@@ -1363,6 +1504,10 @@ sal_Bool SwXTextCursor::gotoEndOfWord(sal_Bool Expand) throw( uno::RuntimeExcept
pPoint->nNode = rOldNode;
pPoint->nContent = nOldIndex;
}
+ else if (CURSOR_META == eType)
+ {
+ bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH);
+ }
}
else
{
@@ -1399,6 +1544,10 @@ sal_Bool SwXTextCursor::gotoStartOfWord(sal_Bool Expand) throw( uno::RuntimeExce
pPoint->nNode = rOldNode;
pPoint->nContent = nOldIndex;
}
+ else if (CURSOR_META == eType)
+ {
+ bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH);
+ }
}
else
{
@@ -1489,6 +1638,11 @@ sal_Bool SwXTextCursor::gotoNextSentence(sal_Bool Expand) throw( uno::RuntimeExc
if (bWasEOS && !bNextWord)
bRet = sal_False;
}
+ if (CURSOR_META == eType)
+ {
+ bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH)
+ && bRet;
+ }
}
else
throw uno::RuntimeException();
@@ -1516,6 +1670,11 @@ sal_Bool SwXTextCursor::gotoPreviousSentence(sal_Bool Expand) throw( uno::Runtim
pUnoCrsr->GoSentence(SwCursor::PREV_SENT);
}
}
+ if (CURSOR_META == eType)
+ {
+ bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH)
+ && bRet;
+ }
}
else
throw uno::RuntimeException();
@@ -1538,6 +1697,11 @@ sal_Bool SwXTextCursor::gotoStartOfSentence(sal_Bool Expand) throw( uno::Runtime
bRet = SwUnoCursorHelper::IsStartOfPara(*pUnoCrsr)
|| pUnoCrsr->GoSentence(SwCursor::START_SENT) ||
SwUnoCursorHelper::IsStartOfPara(*pUnoCrsr);
+ if (CURSOR_META == eType)
+ {
+ bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH)
+ && bRet;
+ }
}
else
throw uno::RuntimeException();
@@ -1561,7 +1725,11 @@ sal_Bool SwXTextCursor::gotoEndOfSentence(sal_Bool Expand) throw( uno::RuntimeEx
bRet = !bAlreadyParaEnd &&
(pUnoCrsr->GoSentence(SwCursor::END_SENT) ||
pUnoCrsr->MovePara(fnParaCurr, fnParaEnd));
-
+ if (CURSOR_META == eType)
+ {
+ bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH)
+ && bRet;
+ }
}
else
throw uno::RuntimeException();
@@ -1603,6 +1771,8 @@ sal_Bool SwXTextCursor::gotoStartOfParagraph(sal_Bool Expand) throw( uno::Runtim
{
vos::OGuard aGuard(Application::GetSolarMutex());
sal_Bool bRet = sal_False;
+ if (CURSOR_META == eType)
+ return bRet;
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(pUnoCrsr )
{
@@ -1627,6 +1797,8 @@ sal_Bool SwXTextCursor::gotoEndOfParagraph(sal_Bool Expand) throw( uno::RuntimeE
{
vos::OGuard aGuard(Application::GetSolarMutex());
sal_Bool bRet = sal_False;
+ if (CURSOR_META == eType)
+ return bRet;
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(pUnoCrsr)
{
@@ -1651,6 +1823,8 @@ sal_Bool SwXTextCursor::gotoNextParagraph(sal_Bool Expand) throw( uno::RuntimeEx
{
vos::OGuard aGuard(Application::GetSolarMutex());
sal_Bool bRet = sal_False;
+ if (CURSOR_META == eType)
+ return bRet;
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(pUnoCrsr)
{
@@ -1668,6 +1842,8 @@ sal_Bool SwXTextCursor::gotoPreviousParagraph(sal_Bool Expand) throw( uno::Runti
{
vos::OGuard aGuard(Application::GetSolarMutex());
sal_Bool bRet = sal_False;
+ if (CURSOR_META == eType)
+ return bRet;
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(pUnoCrsr)
{
@@ -1697,7 +1873,19 @@ uno::Reference< XTextRange > SwXTextCursor::getStart(void) throw( uno::RuntimeE
{
SwPaM aPam(*pUnoCrsr->Start());
uno::Reference< XText > xParent = getText();
- xRet = new SwXTextRange(aPam, xParent);
+ if (CURSOR_META == eType)
+ {
+ // return cursor to prevent modifying SwXTextRange for META
+ SwXTextCursor * const pCursor(
+ new SwXTextCursor(xParent, *pUnoCrsr->GetPoint(),
+ CURSOR_META, pUnoCrsr->GetDoc()) );
+ pCursor->gotoStart(sal_False);
+ xRet = static_cast<text::XWordCursor*>(pCursor);
+ }
+ else
+ {
+ xRet = new SwXTextRange(aPam, xParent);
+ }
}
else
throw uno::RuntimeException();
@@ -1715,7 +1903,19 @@ uno::Reference< XTextRange > SwXTextCursor::getEnd(void) throw( uno::RuntimeExc
{
SwPaM aPam(*pUnoCrsr->End());
uno::Reference< XText > xParent = getText();
- xRet = new SwXTextRange(aPam, xParent);
+ if (CURSOR_META == eType)
+ {
+ // return cursor to prevent modifying SwXTextRange for META
+ SwXTextCursor * const pCursor(
+ new SwXTextCursor(xParent, *pUnoCrsr->GetPoint(),
+ CURSOR_META, pUnoCrsr->GetDoc()) );
+ pCursor->gotoEnd(sal_False);
+ xRet = static_cast<text::XWordCursor*>(pCursor);
+ }
+ else
+ {
+ xRet = new SwXTextRange(aPam, xParent);
+ }
}
else
throw uno::RuntimeException();
@@ -1762,7 +1962,11 @@ void SwXTextCursor::setString(const OUString& aString) throw( uno::RuntimeExcept
if(!pUnoCrsr)
throw uno::RuntimeException();
- DeleteAndInsert(aString);
+ const bool bForceExpandHints( (CURSOR_META != eType)
+ ? false
+ : dynamic_cast<SwXMeta*>(xParentText.get())->CheckForOwnMemberMeta(
+ 0, GetPaM(), true) );
+ DeleteAndInsert(aString, bForceExpandHints);
}
/* -----------------------------03.05.00 12:56--------------------------------
diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx
index 7a27bd597eb0..b7764778d31c 100644
--- a/sw/source/core/unocore/unoobj2.cxx
+++ b/sw/source/core/unocore/unoobj2.cxx
@@ -57,7 +57,6 @@
#include <shellio.hxx>
#include <swerror.h>
#include <swtblfmt.hxx>
-#include <fmthbsh.hxx>
#include <docsh.hxx>
#include <docstyle.hxx>
#include <charfmt.hxx>
@@ -124,6 +123,11 @@
// OD 2004-05-24 #i28701#
#include <sortedobjs.hxx>
+#include <algorithm>
+#include <iterator>
+#include <boost/bind.hpp>
+
+
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
@@ -135,9 +139,20 @@ using namespace ::com::sun::star::drawing;
using ::rtl::OUString;
+
+struct FrameDependSortListLess
+{
+ bool operator() (FrameDependSortListEntry const& r1,
+ FrameDependSortListEntry const& r2)
+ {
+ return (r1.nIndex < r2.nIndex)
+ || ((r1.nIndex == r2.nIndex) && (r1.nOrder < r2.nOrder));
+ }
+};
+
// OD 2004-05-07 #i28701# - adjust 4th parameter
void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx,
- SwDependArr& rFrameArr,
+ FrameDependSortList_t & rFrames,
const bool _bAtCharAnchoredObjs )
{
// _bAtCharAnchoredObjs:
@@ -163,21 +178,21 @@ void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx,
SwFrmFmt& rFmt = pAnchoredObj->GetFrmFmt();
if ( rFmt.GetAnchor().GetAnchorId() == nChkType )
{
- //jetzt einen SwDepend anlegen und in das Array einfuegen
+ // create SwDepend and insert into array
SwDepend* pNewDepend = new SwDepend( &rClnt, &rFmt );
+ xub_StrLen idx =
+ rFmt.GetAnchor().GetCntntAnchor()->nContent.GetIndex();
+ sal_uInt32 nOrder = rFmt.GetAnchor().GetOrder();
// OD 2004-05-07 #i28701# - sorting no longer needed,
// because list <SwSortedObjs> is already sorted.
- rFrameArr.C40_INSERT( SwDepend, pNewDepend, rFrameArr.Count() );
+ FrameDependSortListEntry entry(idx, nOrder, pNewDepend);
+ rFrames.push_back(entry);
}
}
}
else
{
- // OD 2004-05-07 #i28701# - helper list to get <rFrameArr> sorted
- std::vector< std::pair< xub_StrLen, sal_uInt32 > > aSortLst;
- typedef std::vector< std::pair< xub_StrLen, sal_uInt32 > >::iterator tSortLstIter;
-
const SwSpzFrmFmts& rFmts = *pDoc->GetSpzFrmFmts();
USHORT nSize = rFmts.Count();
for ( USHORT i = 0; i < nSize; i++)
@@ -194,32 +209,14 @@ void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx,
// OD 2004-05-07 #i28701# - determine insert position for
// sorted <rFrameArr>
- USHORT nInsPos = rFrameArr.Count();
- {
- xub_StrLen nCntIndex = pAnchorPos->nContent.GetIndex();
- sal_uInt32 nAnchorOrder = rAnchor.GetOrder();
+ xub_StrLen nIndex = pAnchorPos->nContent.GetIndex();
+ sal_uInt32 nOrder = rAnchor.GetOrder();
- tSortLstIter aInsIter = aSortLst.end();
- for ( tSortLstIter aIter = aSortLst.begin();
- aIter != aSortLst.end();
- ++aIter )
- {
- if ( (*aIter).first > nCntIndex ||
- ( (*aIter).first == nCntIndex &&
- (*aIter).second > nAnchorOrder ) )
- {
- nInsPos = sal::static_int_cast< USHORT >(aIter - aSortLst.begin());
- aInsIter = aIter;
- break;
- }
- }
- std::pair< xub_StrLen, sal_uInt32 > aEntry( nCntIndex,
- nAnchorOrder );
- aSortLst.insert( aInsIter, aEntry );
- }
- rFrameArr.C40_INSERT( SwDepend, pNewDepend, nInsPos );
+ FrameDependSortListEntry entry(nIndex, nOrder, pNewDepend);
+ rFrames.push_back(entry);
}
}
+ ::std::sort(rFrames.begin(), rFrames.end(), FrameDependSortListLess());
}
}
@@ -769,7 +766,9 @@ void SwXTextCursor::SetCrsrAttr(SwPaM& rPam, const SfxItemSet& rSet, USHORT nAtt
{
if( _pStartCrsr->HasMark() && ( (CRSR_ATTR_MODE_TABLE & nAttrMode) ||
*_pStartCrsr->GetPoint() != *_pStartCrsr->GetMark() ))
- pDoc->Insert(*_pStartCrsr, rSet, nFlags );
+ {
+ pDoc->InsertItemSet(*_pStartCrsr, rSet, nFlags);
+ }
} while( (_pStartCrsr=(SwPaM *)_pStartCrsr->GetNext()) != &rPam );
pDoc->EndUndo(UNDO_INSATTR, NULL);
@@ -778,7 +777,7 @@ void SwXTextCursor::SetCrsrAttr(SwPaM& rPam, const SfxItemSet& rSet, USHORT nAtt
{
// if( !HasSelection() )
// UpdateAttr();
- pDoc->Insert( *pCrsr, rSet, nFlags );
+ pDoc->InsertItemSet( *pCrsr, rSet, nFlags );
}
//#outline level,add by zhaojianwei
if( rSet.GetItemState( RES_PARATR_OUTLINELEVEL, false ) >= SFX_ITEM_AVAILABLE )
@@ -1214,9 +1213,16 @@ void SwXTextRange::_CreateNewBookmark(SwPaM& rPam)
pMark->Add(this);
}
-void SwXTextRange::DeleteAndInsert(const String& rText)
+void SwXTextRange::DeleteAndInsert(
+ const String& rText, const bool bForceExpandHints)
throw(uno::RuntimeException)
{
+ if (RANGE_IS_TABLE == eRangePosition)
+ {
+ // setString on table not allowed
+ throw uno::RuntimeException();
+ }
+
::sw::mark::IMark const * const pBkmk = GetBookmark();
if(pBkmk)
{
@@ -1231,11 +1237,14 @@ void SwXTextRange::DeleteAndInsert(const String& rText)
UnoActionContext aAction(pDoc);
pDoc->StartUndo(UNDO_INSERT, NULL);
if(aNewCrsr.HasMark())
+ {
pDoc->DeleteAndJoin(aNewCrsr);
+ }
if(rText.Len())
{
- SwUnoCursorHelper::DocInsertStringSplitCR(*pDoc, aNewCrsr, rText);
+ SwUnoCursorHelper::DocInsertStringSplitCR(
+ *pDoc, aNewCrsr, rText, bForceExpandHints);
SwXTextCursor::SelectPam(aNewCrsr, sal_True);
aNewCrsr.Left(rText.Len(), CRSR_SKIP_CHARS, FALSE, FALSE);
@@ -1335,13 +1344,7 @@ void SwXTextRange::setString(const OUString& aString)
throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
- if(RANGE_IS_TABLE == eRangePosition)
- {
- //setString in Tabellen kann nicht erlaubt werden
- throw uno::RuntimeException();
- }
- else
- DeleteAndInsert(aString);
+ DeleteAndInsert(aString, false);
}
void SwXTextRange::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew)
@@ -1438,12 +1441,10 @@ sal_Bool SwXTextRange::XTextRangeToSwPaM( SwUnoInternalPaM& rToFill,
}
else
{
- const SwPaM* pUnoCrsr = 0;
- SwDoc* pDoc = pCursor ? pCursor->GetDoc() : NULL;
-
- if ( !pDoc )
- pDoc = pPortion ? pPortion->GetCrsr()->GetDoc() : NULL;
- pUnoCrsr = pCursor ? pCursor->GetPaM() : pPortion ? pPortion->GetCrsr() : 0;
+ SwDoc* const pDoc = (pCursor) ? pCursor->GetDoc()
+ : ((pPortion) ? pPortion->GetCursor()->GetDoc() : 0);
+ const SwPaM* const pUnoCrsr = (pCursor) ? pCursor->GetPaM()
+ : ((pPortion) ? pPortion->GetCursor() : 0);
if (pUnoCrsr && pDoc == rToFill.GetDoc())
{
DBG_ASSERT((SwPaM*)pUnoCrsr->GetNext() == pUnoCrsr, "was machen wir mit Ringen?" );
@@ -1907,9 +1908,11 @@ sal_Int32 SwXTextRanges::getCount(void) throw( uno::RuntimeException )
SwUnoCrsr* pCrsr = GetCrsr();
if(pCrsr)
{
- FOREACHUNOPAM_START(pCrsr)
+ SwPaM *pTmpCrsr = pCrsr;
+ do {
nRet++;
- FOREACHUNOPAM_END()
+ pTmpCrsr = static_cast<SwPaM*>(pTmpCrsr->GetNext());
+ } while ( pTmpCrsr != pCrsr );
}
else if(pRangeArr)
nRet = pRangeArr->Count();
@@ -1958,15 +1961,20 @@ XTextRangeArr* SwXTextRanges::GetRangesArray()
if(!pRangeArr && pCrsr)
{
pRangeArr = new XTextRangeArr();
- FOREACHUNOPAM_START(pCrsr)
+ SwPaM *pTmpCrsr = pCrsr;
+ do {
uno::Reference< XTextRange >* pPtr =
- new uno::Reference<XTextRange>( SwXTextRange::CreateTextRangeFromPosition(PUNOPAM->GetDoc(),
- *PUNOPAM->GetPoint(), PUNOPAM->GetMark()));
-// new uno::Reference<XTextRange>( SwXTextRange::createTextRangeFromPaM(*PUNOPAM, xParentText));
+ new uno::Reference<XTextRange>(
+ SwXTextRange::CreateTextRangeFromPosition(
+ pTmpCrsr->GetDoc(),
+ *pTmpCrsr->GetPoint(), pTmpCrsr->GetMark()));
+// new uno::Reference<XTextRange>( SwXTextRange::createTextRangeFromPaM(*pTmpCrsr, xParentText));
if(pPtr->is())
pRangeArr->Insert(pPtr, pRangeArr->Count());
- FOREACHUNOPAM_END()
+
+ pTmpCrsr = static_cast<SwPaM*>(pTmpCrsr->GetNext());
+ } while ( pTmpCrsr != pCrsr );
pCrsr->Remove( this );
}
return pRangeArr;
@@ -1994,37 +2002,107 @@ void SwXTextCursor::SetString(SwCursor& rCrsr, const OUString& rString)
pDoc->DeleteAndJoin(rCrsr);
if(nTxtLen)
{
- if( !SwUnoCursorHelper::DocInsertStringSplitCR( *pDoc, rCrsr, aText ) )
- {
- DBG_ASSERT( sal_False, "DocInsertStringSplitCR" );
- }
+ const bool bSuccess( SwUnoCursorHelper::DocInsertStringSplitCR(
+ *pDoc, rCrsr, aText, false ) );
+ DBG_ASSERT( bSuccess, "DocInsertStringSplitCR" );
+ (void) bSuccess;
SwXTextCursor::SelectPam(rCrsr, sal_True);
rCrsr.Left(nTxtLen, CRSR_SKIP_CHARS, FALSE, FALSE);
}
pDoc->EndUndo(UNDO_INSERT, NULL);
}
+
/******************************************************************
* SwXParaFrameEnumeration
******************************************************************/
-SV_IMPL_PTRARR(SwDependArr, SwDepend*);
+
+/* -----------------23.03.99 13:38-------------------
+ *
+ * --------------------------------------------------*/
+static sal_Bool
+lcl_CreateNextObject(SwUnoCrsr& i_rUnoCrsr,
+ uno::Reference<text::XTextContent> & o_rNextObject,
+ FrameDependList_t & i_rFrames)
+{
+ if (!i_rFrames.size())
+ return sal_False;
+
+ SwFrmFmt* pFormat = static_cast<SwFrmFmt*>(const_cast<SwModify*>(
+ i_rFrames.front()->GetRegisteredIn()));
+ i_rFrames.pop_front();
+ // the format should be valid here, otherwise the client
+ // would have been removed in ::Modify
+ // check for a shape first
+ SwClientIter aIter(*pFormat);
+ SwDrawContact * const pContact =
+ static_cast<SwDrawContact*>( aIter.First(TYPE(SwDrawContact)) );
+ if (pContact)
+ {
+ SdrObject * const pSdr = pContact->GetMaster();
+ if (pSdr)
+ {
+ o_rNextObject.set(pSdr->getUnoShape(), uno::UNO_QUERY);
+ }
+ }
+ else
+ {
+ const SwNodeIndex* pIdx = pFormat->GetCntnt().GetCntntIdx();
+ DBG_ASSERT(pIdx, "where is the index?");
+ const SwNode* pNd =
+ i_rUnoCrsr.GetDoc()->GetNodes()[ pIdx->GetIndex() + 1 ];
+
+ const FlyCntType eType = (!pNd->IsNoTxtNode()) ? FLYCNTTYPE_FRM
+ : ( (pNd->IsGrfNode()) ? FLYCNTTYPE_GRF : FLYCNTTYPE_OLE );
+
+ const uno::Reference< container::XNamed > xFrame =
+ SwXFrames::GetObject(*pFormat, eType);
+ o_rNextObject.set(xFrame, uno::UNO_QUERY);
+ }
+
+ return o_rNextObject.is();
+}
+
+/* -----------------------------03.04.00 10:15--------------------------------
+ Description: Search for a FLYCNT text attribute at the cursor point
+ and fill the frame into the array
+ ---------------------------------------------------------------------------*/
+static void
+lcl_FillFrame(SwXParaFrameEnumeration & rEnum, SwUnoCrsr& rUnoCrsr,
+ FrameDependList_t & rFrames)
+{
+ // search for objects at the cursor - anchored at/as char
+ const SwTxtAttr * pTxtAttr = rUnoCrsr.GetNode()->GetTxtNode()->GetTxtAttr(
+ rUnoCrsr.GetPoint()->nContent, RES_TXTATR_FLYCNT);
+ if (pTxtAttr)
+ {
+ const SwFmtFlyCnt& rFlyCnt = pTxtAttr->GetFlyCnt();
+ SwFrmFmt * const pFrmFmt = rFlyCnt.GetFrmFmt();
+ SwDepend * const pNewDepend = new SwDepend(&rEnum, pFrmFmt);
+ rFrames.push_back( ::boost::shared_ptr<SwDepend>(pNewDepend) );
+ }
+}
+
/* -----------------------------06.04.00 16:39--------------------------------
---------------------------------------------------------------------------*/
-OUString SwXParaFrameEnumeration::getImplementationName(void) throw( RuntimeException )
+OUString SwXParaFrameEnumeration::getImplementationName()
+throw( RuntimeException )
{
return C2U("SwXParaFrameEnumeration");
}
/* -----------------------------06.04.00 16:39--------------------------------
---------------------------------------------------------------------------*/
-BOOL SwXParaFrameEnumeration::supportsService(const OUString& rServiceName) throw( RuntimeException )
+sal_Bool SwXParaFrameEnumeration::supportsService(const OUString& rServiceName)
+throw( RuntimeException )
{
return C2U("com.sun.star.util.ContentEnumeration") == rServiceName;
}
/* -----------------------------06.04.00 16:39--------------------------------
---------------------------------------------------------------------------*/
-Sequence< OUString > SwXParaFrameEnumeration::getSupportedServiceNames(void) throw( RuntimeException )
+Sequence< OUString > SwXParaFrameEnumeration::getSupportedServiceNames()
+throw( RuntimeException )
{
Sequence< OUString > aRet(1);
OUString* pArray = aRet.getArray();
@@ -2049,14 +2127,17 @@ SwXParaFrameEnumeration::SwXParaFrameEnumeration(const SwPaM& rPaM,
if (PARAFRAME_PORTION_PARAGRAPH == nParaFrameMode)
{
- ::CollectFrameAtNode( *this, rPaM.GetPoint()->nNode,
- aFrameArr, FALSE );
+ FrameDependSortList_t frames;
+ ::CollectFrameAtNode( *this, rPaM.GetPoint()->nNode, frames, false );
+ ::std::transform(frames.begin(), frames.end(),
+ ::std::back_inserter(m_Frames),
+ ::boost::bind(&FrameDependSortListEntry::pFrameDepend, _1));
}
else if (pFmt)
{
//jetzt einen SwDepend anlegen und in das Array einfuegen
SwDepend* pNewDepend = new SwDepend(this, pFmt);
- aFrameArr.C40_INSERT(SwDepend, pNewDepend, aFrameArr.Count());
+ m_Frames.push_back( ::boost::shared_ptr<SwDepend>(pNewDepend) );
}
else if((PARAFRAME_PORTION_CHAR == nParaFrameMode) ||
(PARAFRAME_PORTION_TEXTRANGE == nParaFrameMode))
@@ -2072,7 +2153,7 @@ SwXParaFrameEnumeration::SwXParaFrameEnumeration(const SwPaM& rPaM,
SwFrmFmt* pFrmFmt = (SwFrmFmt*)&pPosFly->GetFmt();
//jetzt einen SwDepend anlegen und in das Array einfuegen
SwDepend* pNewDepend = new SwDepend(this, pFrmFmt);
- aFrameArr.C40_INSERT(SwDepend, pNewDepend, aFrameArr.Count());
+ m_Frames.push_back( ::boost::shared_ptr<SwDepend>(pNewDepend) );
}
//created from any text range
if(pUnoCrsr->HasMark())
@@ -2081,13 +2162,13 @@ SwXParaFrameEnumeration::SwXParaFrameEnumeration(const SwPaM& rPaM,
pUnoCrsr->Exchange();
do
{
- FillFrame(*pUnoCrsr);
+ lcl_FillFrame(*this, *pUnoCrsr, m_Frames);
pUnoCrsr->Right(1, CRSR_SKIP_CHARS, FALSE, FALSE);
}
while(*pUnoCrsr->GetPoint() < *pUnoCrsr->GetMark());
}
}
- FillFrame(*pUnoCrsr);
+ lcl_FillFrame(*this, *pUnoCrsr, m_Frames);
}
}
/*-- 23.03.99 13:22:30---------------------------------------------------
@@ -2096,102 +2177,53 @@ SwXParaFrameEnumeration::SwXParaFrameEnumeration(const SwPaM& rPaM,
SwXParaFrameEnumeration::~SwXParaFrameEnumeration()
{
vos::OGuard aGuard(Application::GetSolarMutex());
- aFrameArr.DeleteAndDestroy(0, aFrameArr.Count());
- SwUnoCrsr* pUnoCrsr = GetCrsr();
+
+ SwUnoCrsr* pUnoCrsr = GetCursor();
delete pUnoCrsr;
}
-/* -----------------------------03.04.00 10:15--------------------------------
- Description: Search for a FLYCNT text attribute at the cursor point
- and fill the frame into the array
- ---------------------------------------------------------------------------*/
-void SwXParaFrameEnumeration::FillFrame(SwUnoCrsr& rUnoCrsr)
-{
- // search for objects at the cursor - anchored at/as char
- SwTxtAttr* pTxtAttr = rUnoCrsr.GetNode()->GetTxtNode()->GetTxtAttr(
- rUnoCrsr.GetPoint()->nContent, RES_TXTATR_FLYCNT);
- if(pTxtAttr)
- {
- const SwFmtFlyCnt& rFlyCnt = pTxtAttr->GetFlyCnt();
- SwFrmFmt* pFrmFmt = rFlyCnt.GetFrmFmt();
- //jetzt einen SwDepend anlegen und in das Array einfuegen
- SwDepend* pNewDepend = new SwDepend(this, pFrmFmt);
- aFrameArr.C40_INSERT(SwDepend, pNewDepend, aFrameArr.Count());
- }
-}
+
/*-- 23.03.99 13:22:32---------------------------------------------------
-----------------------------------------------------------------------*/
-sal_Bool SwXParaFrameEnumeration::hasMoreElements(void) throw( uno::RuntimeException )
+sal_Bool SwXParaFrameEnumeration::hasMoreElements()
+throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
- if(!GetCrsr())
+
+ if (!GetCursor())
throw uno::RuntimeException();
- return xNextObject.is() ? sal_True : CreateNextObject();
+
+ return m_xNextObject.is() ? sal_True :
+ lcl_CreateNextObject(*GetCursor(), m_xNextObject, m_Frames);
}
/*-- 23.03.99 13:22:33---------------------------------------------------
-----------------------------------------------------------------------*/
-uno::Any SwXParaFrameEnumeration::nextElement(void)
- throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
+uno::Any SwXParaFrameEnumeration::nextElement()
+ throw( container::NoSuchElementException,
+ lang::WrappedTargetException, uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
- if(!GetCrsr())
+
+ if (!GetCursor())
throw uno::RuntimeException();
- if(!xNextObject.is() && aFrameArr.Count())
+
+ if (!m_xNextObject.is() && m_Frames.size())
{
- CreateNextObject();
+ lcl_CreateNextObject(*GetCursor(), m_xNextObject, m_Frames);
}
- if(!xNextObject.is())
+ if(!m_xNextObject.is())
throw container::NoSuchElementException();
- uno::Any aRet(&xNextObject, ::getCppuType((uno::Reference<XTextContent>*)0));
- xNextObject = 0;
+ uno::Any aRet(&m_xNextObject,
+ ::getCppuType((uno::Reference<XTextContent>*)0));
+ m_xNextObject = 0;
return aRet;
}
-/* -----------------23.03.99 13:38-------------------
- *
- * --------------------------------------------------*/
-sal_Bool SwXParaFrameEnumeration::CreateNextObject()
-{
- if(!aFrameArr.Count())
- return sal_False;
- SwDepend* pDepend = aFrameArr.GetObject(0);
- aFrameArr.Remove(0);
- SwFrmFmt* pFormat = (SwFrmFmt*)pDepend->GetRegisteredIn();
- delete pDepend;
- // the format should be valid her otherwise the client
- // would have been removed in ::Modify
- // check for a shape first
- SwClientIter aIter(*pFormat);
- SwDrawContact* pContact = (SwDrawContact*)
- aIter.First(TYPE(SwDrawContact));
- if(pContact)
- {
- SdrObject* pSdr = pContact->GetMaster();
- if(pSdr)
- {
- xNextObject = uno::Reference< XTextContent >(pSdr->getUnoShape(), uno::UNO_QUERY);
- }
- }
- else
- {
- const SwNodeIndex* pIdx = pFormat->GetCntnt().GetCntntIdx();
- DBG_ASSERT(pIdx, "where is the index?");
- const SwNode* pNd = GetCrsr()->GetDoc()->GetNodes()[ pIdx->GetIndex() + 1 ];
- FlyCntType eType;
- if(!pNd->IsNoTxtNode())
- eType = FLYCNTTYPE_FRM;
- else if(pNd->IsGrfNode())
- eType = FLYCNTTYPE_GRF;
- else
- eType = FLYCNTTYPE_OLE;
-
- uno::Reference< container::XNamed > xFrame = SwXFrames::GetObject(*pFormat, eType);
- xNextObject = uno::Reference< XTextContent >(xFrame, uno::UNO_QUERY);
- }
-
- return xNextObject.is();
-}
+struct InvalidFrameDepend {
+ bool operator() (::boost::shared_ptr<SwDepend> const & rEntry)
+ { return !rEntry->GetRegisteredIn(); }
+};
/*-- 23.03.99 13:22:37---------------------------------------------------
@@ -2215,21 +2247,16 @@ void SwXParaFrameEnumeration::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew)
}
if(!GetRegisteredIn())
{
- aFrameArr.DeleteAndDestroy(0, aFrameArr.Count());
- xNextObject = 0;
+ m_Frames.clear();
+ m_xNextObject = 0;
}
else
{
- //dann war es vielleicht ein Frame am Absatz?
- for(sal_uInt16 i = aFrameArr.Count(); i; i--)
- {
- SwDepend* pDepend = aFrameArr.GetObject(i-1);
- if(!pDepend->GetRegisteredIn())
- {
- delete pDepend;
- aFrameArr.Remove(i-1);
- }
- }
+ // check if any frame went away...
+ FrameDependList_t::iterator iter =
+ ::std::remove_if(m_Frames.begin(), m_Frames.end(),
+ InvalidFrameDepend());
+ m_Frames.erase(iter, m_Frames.end());
}
}
// -----------------------------------------------------------------------------
diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx
index d21439ff120e..227b8cf58e42 100644
--- a/sw/source/core/unocore/unoparagraph.cxx
+++ b/sw/source/core/unocore/unoparagraph.cxx
@@ -35,6 +35,7 @@
#include <cmdid.h>
#include <unomid.h>
#include <unoobj.hxx>
+#include <unoport.hxx>
#include <unomap.hxx>
#include <unocrsr.hxx>
#include <unoprnms.hxx>
diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx
index e2db326202d9..04d073a09df3 100644
--- a/sw/source/core/unocore/unoport.cxx
+++ b/sw/source/core/unocore/unoport.cxx
@@ -41,20 +41,20 @@
#include <unoobj.hxx>
#include <unomap.hxx>
#include <unoprnms.hxx>
-#ifndef _UNOMID_H
#include <unomid.h>
-#endif
#include <txtatr.hxx>
#include <txtfld.hxx>
#include <ndtxt.hxx>
#include <doc.hxx>
#include <fmtflcnt.hxx>
#include <fmtfld.hxx>
+
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/beans/SetPropertyTolerantFailed.hpp>
#include <com/sun/star/beans/GetPropertyTolerantResult.hpp>
#include <com/sun/star/beans/TolerantPropertySetResultType.hpp>
+
using namespace ::com::sun::star;
using ::rtl::OUString;
@@ -63,88 +63,95 @@ using ::rtl::OUString;
* SwXTextPortion
******************************************************************/
-/*-- 11.12.98 09:56:52---------------------------------------------------
-
- -----------------------------------------------------------------------*/
-SwFmtFld* SwXTextPortion::GetFldFmt(sal_Bool bInit)
+static void init(SwXTextPortion & rPortion, const SwUnoCrsr* pPortionCursor)
{
- SwFmtFld* pRet = 0;
- // initial wird es immer gesucht, danach nur noch, wenn es bereits existierte
- SwUnoCrsr* pUnoCrsr = GetCrsr();
- if(pUnoCrsr && (bInit || pFmtFld))
+ SwUnoCrsr* pUnoCursor =
+ pPortionCursor->GetDoc()->CreateUnoCrsr(*pPortionCursor->GetPoint());
+ if (pPortionCursor->HasMark())
{
- SwTxtNode *pNode = pUnoCrsr->GetPoint()->nNode.GetNode().GetTxtNode();
- SwTxtFld *pTxtFld = 0;
- if( pNode )
- pTxtFld = pNode->GetTxtFld( pUnoCrsr->Start()->nContent );
- if(pTxtFld)
- pFmtFld = pRet = (SwFmtFld*)&pTxtFld->GetFld();
+ pUnoCursor->SetMark();
+ *pUnoCursor->GetMark() = *pPortionCursor->GetMark();
}
- return pRet;
+ pUnoCursor->Add(& rPortion);
}
+
/*-- 11.12.98 09:56:55---------------------------------------------------
-----------------------------------------------------------------------*/
SwXTextPortion::SwXTextPortion(const SwUnoCrsr* pPortionCrsr,
uno::Reference< text::XText > const& rParent,
- SwTextPortionType eType) :
- aLstnrCntnr( (text::XTextRange*)this),
- m_pPropSet(aSwMapProvider.GetPropertySet(
- (PORTION_REDLINE_START == eType ||
- PORTION_REDLINE_END == eType) ?
- PROPERTY_MAP_REDLINE_PORTION : PROPERTY_MAP_TEXTPORTION_EXTENSIONS)),
- xParentText(rParent),
- pRubyText(0),
- pRubyStyle(0),
- pRubyAdjust(0),
- pRubyIsAbove(0),
- pFmtFld(0),
- aFrameDepend(this, 0),
- pFrameFmt(0),
- ePortionType(eType),
- nControlChar(0),
- bIsCollapsed(FALSE)
+ SwTextPortionType eType)
+ : m_ListenerContainer( static_cast<text::XTextRange*>(this) )
+ , m_pPropSet(aSwMapProvider.GetPropertySet(
+ (PORTION_REDLINE_START == eType ||
+ PORTION_REDLINE_END == eType)
+ ? PROPERTY_MAP_REDLINE_PORTION
+ : PROPERTY_MAP_TEXTPORTION_EXTENSIONS))
+ , m_xParentText(rParent)
+ , m_pRubyText(0)
+ , m_pRubyStyle(0)
+ , m_pRubyAdjust(0)
+ , m_pRubyIsAbove(0)
+ , m_FrameDepend(this, 0)
+ , m_pFrameFmt(0)
+ , m_ePortionType(eType)
+ , m_bIsCollapsed(false)
{
- SwUnoCrsr* pUnoCrsr = pPortionCrsr->GetDoc()->CreateUnoCrsr(*pPortionCrsr->GetPoint());
- if(pPortionCrsr->HasMark())
- {
- pUnoCrsr->SetMark();
- *pUnoCrsr->GetMark() = *pPortionCrsr->GetMark();
- }
- pUnoCrsr->Add(this);
- // erst nach ->Add()
- if(ePortionType == PORTION_FIELD)
- GetFldFmt(sal_True);
-// else if(ePortionType == PORTION_FRAME)
-// ...;
+ init(*this, pPortionCrsr);
}
+
/* -----------------24.03.99 16:30-------------------
*
* --------------------------------------------------*/
SwXTextPortion::SwXTextPortion(const SwUnoCrsr* pPortionCrsr,
uno::Reference< text::XText > const& rParent,
- SwFrmFmt& rFmt ) :
- aLstnrCntnr( (text::XTextRange*)this),
- m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXTPORTION_EXTENSIONS)),
- xParentText(rParent),
- pRubyText(0),
- pRubyStyle(0),
- pRubyAdjust(0),
- pRubyIsAbove(0),
- pFmtFld(0),
- aFrameDepend(this, &rFmt),
- pFrameFmt(&rFmt),
- ePortionType(PORTION_FRAME),
- nControlChar(0),
- bIsCollapsed(FALSE)
+ SwFrmFmt& rFmt )
+ : m_ListenerContainer( static_cast<text::XTextRange*>(this) )
+ , m_pPropSet(aSwMapProvider.GetPropertySet(
+ PROPERTY_MAP_TEXTPORTION_EXTENSIONS))
+ , m_xParentText(rParent)
+ , m_pRubyText(0)
+ , m_pRubyStyle(0)
+ , m_pRubyAdjust(0)
+ , m_pRubyIsAbove(0)
+ , m_FrameDepend(this, &rFmt)
+ , m_pFrameFmt(&rFmt)
+ , m_ePortionType(PORTION_FRAME)
+ , m_bIsCollapsed(false)
{
- SwUnoCrsr* pUnoCrsr = pPortionCrsr->GetDoc()->CreateUnoCrsr(*pPortionCrsr->GetPoint());
- if(pPortionCrsr->HasMark())
+ init(*this, pPortionCrsr);
+}
+
+/* -----------------------------19.02.01 10:52--------------------------------
+
+ ---------------------------------------------------------------------------*/
+SwXTextPortion::SwXTextPortion(const SwUnoCrsr* pPortionCrsr,
+ SwTxtRuby const& rAttr,
+ uno::Reference< text::XText > const& xParent,
+ sal_Bool bIsEnd )
+ : m_ListenerContainer( static_cast<text::XTextRange*>(this) )
+ , m_pPropSet(aSwMapProvider.GetPropertySet(
+ PROPERTY_MAP_TEXTPORTION_EXTENSIONS))
+ , m_xParentText(xParent)
+ , m_pRubyText ( bIsEnd ? 0 : new uno::Any )
+ , m_pRubyStyle ( bIsEnd ? 0 : new uno::Any )
+ , m_pRubyAdjust ( bIsEnd ? 0 : new uno::Any )
+ , m_pRubyIsAbove( bIsEnd ? 0 : new uno::Any )
+ , m_FrameDepend(this, 0)
+ , m_pFrameFmt(0)
+ , m_ePortionType( bIsEnd ? PORTION_RUBY_END : PORTION_RUBY_START )
+ , m_bIsCollapsed(false)
+{
+ init(*this, pPortionCrsr);
+
+ if (!bIsEnd)
{
- pUnoCrsr->SetMark();
- *pUnoCrsr->GetMark() = *pPortionCrsr->GetMark();
+ const SfxPoolItem& rItem = rAttr.GetAttr();
+ rItem.QueryValue(*m_pRubyText, MID_RUBY_TEXT);
+ rItem.QueryValue(*m_pRubyStyle, MID_RUBY_CHARSTYLE);
+ rItem.QueryValue(*m_pRubyAdjust, MID_RUBY_ADJUST);
+ rItem.QueryValue(*m_pRubyIsAbove, MID_RUBY_ABOVE);
}
- pUnoCrsr->Add(this);
}
/*-- 11.12.98 09:56:55---------------------------------------------------
@@ -153,77 +160,71 @@ SwXTextPortion::SwXTextPortion(const SwUnoCrsr* pPortionCrsr,
SwXTextPortion::~SwXTextPortion()
{
vos::OGuard aGuard(Application::GetSolarMutex());
- SwUnoCrsr* pUnoCrsr = GetCrsr();
+ SwUnoCrsr* pUnoCrsr = GetCursor();
delete pUnoCrsr;
- delete pRubyText;
- delete pRubyStyle;
- delete pRubyAdjust;
- delete pRubyIsAbove;
}
/*-- 11.12.98 09:56:56---------------------------------------------------
-----------------------------------------------------------------------*/
-uno::Reference< text::XText > SwXTextPortion::getText(void) throw( uno::RuntimeException )
+uno::Reference< text::XText > SwXTextPortion::getText()
+throw( uno::RuntimeException )
{
- return xParentText;
+ return m_xParentText;
}
/*-- 11.12.98 09:56:56---------------------------------------------------
-----------------------------------------------------------------------*/
-uno::Reference< text::XTextRange > SwXTextPortion::getStart(void) throw( uno::RuntimeException )
+uno::Reference< text::XTextRange > SwXTextPortion::getStart()
+throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
uno::Reference< text::XTextRange > xRet;
- SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr();
- if(pUnoCrsr)
- {
- SwPaM aPam(*pUnoCrsr->Start());
- uno::Reference< text::XText > xParent = getText();
- xRet = new SwXTextRange(aPam, xParent);
- }
- else
+ SwUnoCrsr* pUnoCrsr = GetCursor();
+ if (!pUnoCrsr)
throw uno::RuntimeException();
+
+ SwPaM aPam(*pUnoCrsr->Start());
+ uno::Reference< text::XText > xParent = getText();
+ xRet = new SwXTextRange(aPam, xParent);
return xRet;
}
/*-- 11.12.98 09:56:57---------------------------------------------------
-----------------------------------------------------------------------*/
-uno::Reference< text::XTextRange > SwXTextPortion::getEnd(void) throw( uno::RuntimeException )
+uno::Reference< text::XTextRange > SwXTextPortion::getEnd()
+throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
uno::Reference< text::XTextRange > xRet;
- SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr();
- if(pUnoCrsr)
- {
- SwPaM aPam(*pUnoCrsr->End());
- uno::Reference< text::XText > xParent = getText();
- xRet = new SwXTextRange(aPam, xParent);
- }
- else
+ SwUnoCrsr* pUnoCrsr = GetCursor();
+ if (!pUnoCrsr)
throw uno::RuntimeException();
+
+ SwPaM aPam(*pUnoCrsr->End());
+ uno::Reference< text::XText > xParent = getText();
+ xRet = new SwXTextRange(aPam, xParent);
return xRet;
}
/*-- 11.12.98 09:56:57---------------------------------------------------
-----------------------------------------------------------------------*/
-OUString SwXTextPortion::getString(void) throw( uno::RuntimeException )
+OUString SwXTextPortion::getString()
+throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
- String aTxt;
- SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr();
- if(pUnoCrsr)
+ OUString aTxt;
+ SwUnoCrsr* pUnoCrsr = GetCursor();
+ if (!pUnoCrsr)
+ throw uno::RuntimeException();
+
+ // TextPortions are always within a paragraph
+ SwTxtNode* pTxtNd = pUnoCrsr->GetNode()->GetTxtNode();
+ if ( pTxtNd )
{
- //TextPortions liegen immer innerhalb eines Absatzes
- SwTxtNode* pTxtNd = pUnoCrsr->GetNode()->GetTxtNode();
- if( pTxtNd )
- {
- xub_StrLen nStt = pUnoCrsr->Start()->nContent.GetIndex();
- aTxt = pTxtNd->GetExpandTxt( nStt,
- pUnoCrsr->End()->nContent.GetIndex() - nStt );
- }
+ xub_StrLen nStt = pUnoCrsr->Start()->nContent.GetIndex();
+ aTxt = pTxtNd->GetExpandTxt( nStt,
+ pUnoCrsr->End()->nContent.GetIndex() - nStt );
}
- else
- throw uno::RuntimeException();
return aTxt;
}
/*-- 11.12.98 09:56:57---------------------------------------------------
@@ -232,17 +233,19 @@ OUString SwXTextPortion::getString(void) throw( uno::RuntimeException )
void SwXTextPortion::setString(const OUString& aString) throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
- SwUnoCrsr* pUnoCrsr = GetCrsr();
- if(pUnoCrsr)
- SwXTextCursor::SetString(*pUnoCrsr, aString);
- else
+ SwUnoCrsr* pUnoCrsr = GetCursor();
+ if (!pUnoCrsr)
throw uno::RuntimeException();
+
+ SwXTextCursor::SetString(*pUnoCrsr, aString);
}
/*-- 11.12.98 09:56:57---------------------------------------------------
-----------------------------------------------------------------------*/
-uno::Reference< beans::XPropertySetInfo > SwXTextPortion::getPropertySetInfo(void) throw( uno::RuntimeException )
+uno::Reference< beans::XPropertySetInfo > SwXTextPortion::getPropertySetInfo()
+throw( uno::RuntimeException )
{
+ vos::OGuard aGuard(Application::GetSolarMutex());
//! PropertySetInfo for text portion extensions
static uno::Reference< beans::XPropertySetInfo >
xTxtPorExtRef = aSwMapProvider.GetPropertySet(
@@ -252,8 +255,8 @@ uno::Reference< beans::XPropertySetInfo > SwXTextPortion::getPropertySetInfo(vo
xRedlPorRef = aSwMapProvider.GetPropertySet(
PROPERTY_MAP_REDLINE_PORTION)->getPropertySetInfo();
- return (PORTION_REDLINE_START == ePortionType ||
- PORTION_REDLINE_END == ePortionType) ? xRedlPorRef : xTxtPorExtRef;
+ return (PORTION_REDLINE_START == m_ePortionType ||
+ PORTION_REDLINE_END == m_ePortionType) ? xRedlPorRef : xTxtPorExtRef;
}
/*-- 11.12.98 09:56:57---------------------------------------------------
@@ -264,13 +267,12 @@ void SwXTextPortion::setPropertyValue(const OUString& rPropertyName,
beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
- SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr();
- if(pUnoCrsr)
- {
- SwXTextCursor::SetPropertyValue(*pUnoCrsr, *m_pPropSet, rPropertyName, aValue);
- }
- else
+ SwUnoCrsr* pUnoCrsr = GetCursor();
+ if (!pUnoCrsr)
throw uno::RuntimeException();
+
+ SwXTextCursor::SetPropertyValue(*pUnoCrsr, *m_pPropSet,
+ rPropertyName, aValue);
}
/*-- 04.11.03 09:56:58---------------------------------------------------
@@ -291,13 +293,12 @@ void SwXTextPortion::GetPropertyValue(
case FN_UNO_TEXT_PORTION_TYPE:
{
const char* pRet;
- switch (ePortionType)
+ switch (m_ePortionType)
{
case PORTION_TEXT: pRet = "Text";break;
case PORTION_FIELD: pRet = "TextField";break;
case PORTION_FRAME: pRet = "Frame";break;
case PORTION_FOOTNOTE: pRet = "Footnote";break;
- case PORTION_CONTROL_CHAR: pRet = "ControlCharacter";break;
case PORTION_REFMARK_START:
case PORTION_REFMARK_END: pRet = SW_PROP_NAME_STR(UNO_NAME_REFERENCE_MARK);break;
case PORTION_TOXMARK_START:
@@ -309,6 +310,7 @@ void SwXTextPortion::GetPropertyValue(
case PORTION_RUBY_START:
case PORTION_RUBY_END: pRet = "Ruby";break;
case PORTION_SOFT_PAGEBREAK:pRet = "SoftPageBreak";break;
+ case PORTION_META: pRet = SW_PROP_NAME_STR(UNO_NAME_META); break;
case PORTION_FIELD_START:pRet = "TextFieldStart";break;
case PORTION_FIELD_END:pRet = "TextFieldEnd";break;
case PORTION_FIELD_START_END:pRet = "TextFieldStartEnd";break;
@@ -322,28 +324,29 @@ void SwXTextPortion::GetPropertyValue(
rVal <<= sRet;
}
break;
- case FN_UNO_CONTROL_CHARACTER:
- {
- if(PORTION_CONTROL_CHAR == ePortionType)
- rVal <<= (sal_Int16) nControlChar;
- }
+ case FN_UNO_CONTROL_CHARACTER: // obsolete!
break;
case FN_UNO_DOCUMENT_INDEX_MARK:
- rVal <<= xTOXMark;
+ rVal <<= m_xTOXMark;
break;
case FN_UNO_REFERENCE_MARK:
- rVal <<= xRefMark;
+ rVal <<= m_xRefMark;
break;
case FN_UNO_BOOKMARK:
- rVal <<= xBookmark;
+ rVal <<= m_xBookmark;
break;
case FN_UNO_FOOTNOTE:
- rVal <<= xFootnote;
+ rVal <<= m_xFootnote;
+ break;
+ case FN_UNO_TEXT_FIELD:
+ rVal <<= m_xTextField;
+ break;
+ case FN_UNO_META:
+ rVal <<= m_xMeta;
break;
case FN_UNO_IS_COLLAPSED:
{
- BOOL bPut = TRUE;
- switch (ePortionType)
+ switch (m_ePortionType)
{
case PORTION_REFMARK_START:
case PORTION_BOOKMARK_START :
@@ -357,17 +360,17 @@ void SwXTextPortion::GetPropertyValue(
case PORTION_RUBY_END:
case PORTION_FIELD_START:
case PORTION_FIELD_END:
- rVal.setValue(&bIsCollapsed, ::getBooleanCppuType());
+ rVal.setValue(&m_bIsCollapsed, ::getBooleanCppuType());
break;
default:
- bPut = FALSE;
+ break;
}
}
break;
case FN_UNO_IS_START:
{
BOOL bStart = TRUE, bPut = TRUE;
- switch (ePortionType)
+ switch (m_ePortionType)
{
case PORTION_REFMARK_START:
case PORTION_BOOKMARK_START:
@@ -394,13 +397,13 @@ void SwXTextPortion::GetPropertyValue(
break;
case RES_TXTATR_CJK_RUBY:
{
- uno::Any* pToSet = 0;
+ const uno::Any* pToSet = 0;
switch(rEntry.nMemberId)
{
- case MID_RUBY_TEXT : pToSet = pRubyText; break;
- case MID_RUBY_ADJUST : pToSet = pRubyAdjust; break;
- case MID_RUBY_CHARSTYLE:pToSet = pRubyStyle; break;
- case MID_RUBY_ABOVE : pToSet = pRubyIsAbove; break;
+ case MID_RUBY_TEXT : pToSet = m_pRubyText.get(); break;
+ case MID_RUBY_ADJUST : pToSet = m_pRubyAdjust.get(); break;
+ case MID_RUBY_CHARSTYLE:pToSet = m_pRubyStyle.get(); break;
+ case MID_RUBY_ABOVE : pToSet = m_pRubyIsAbove.get();break;
}
if(pToSet)
rVal = *pToSet;
@@ -436,8 +439,10 @@ uno::Sequence< uno::Any > SAL_CALL SwXTextPortion::GetPropertyValues_Impl(
const OUString *pPropertyNames = rPropertyNames.getConstArray();
uno::Sequence< uno::Any > aValues(rPropertyNames.getLength());
uno::Any *pValues = aValues.getArray();
- SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr();
- if(pUnoCrsr)
+ SwUnoCrsr* pUnoCrsr = GetCursor();
+ if (!pUnoCrsr)
+ throw uno::RuntimeException();
+
{
SfxItemSet *pSet = 0;
// get startting pount fo the look-up, either the provided one or else
@@ -455,8 +460,6 @@ uno::Sequence< uno::Any > SAL_CALL SwXTextPortion::GetPropertyValues_Impl(
}
delete pSet;
}
- else
- throw uno::RuntimeException();
return aValues;
}
/*-- 11.12.98 09:56:58---------------------------------------------------
@@ -480,8 +483,10 @@ void SAL_CALL SwXTextPortion::SetPropertyValues_Impl(
throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException,
lang::WrappedTargetException, uno::RuntimeException)
{
- SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr();
- if(pUnoCrsr)
+ SwUnoCrsr* pUnoCrsr = GetCursor();
+ if (!pUnoCrsr)
+ throw uno::RuntimeException();
+
{
const OUString* pPropertyNames = rPropertyNames.getConstArray();
const uno::Any* pValues = rValues.getConstArray();
@@ -494,11 +499,10 @@ void SAL_CALL SwXTextPortion::SetPropertyValues_Impl(
if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + pPropertyNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
- SwXTextCursor::SetPropertyValue( *pUnoCrsr, *m_pPropSet, pPropertyNames[nProp], pValues[nProp]);
+ SwXTextCursor::SetPropertyValue( *pUnoCrsr, *m_pPropSet,
+ pPropertyNames[nProp], pValues[nProp]);
}
}
- else
- throw uno::RuntimeException();
}
void SwXTextPortion::setPropertyValues(
@@ -564,7 +568,7 @@ uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL SwXTextPortion::setPr
if (rPropertyNames.getLength() != rValues.getLength())
throw lang::IllegalArgumentException();
- SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr();
+ SwUnoCrsr* pUnoCrsr = this->GetCursor();
if (!pUnoCrsr)
throw uno::RuntimeException();
@@ -664,7 +668,7 @@ uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXTextPortion:
{
vos::OGuard aGuard(Application::GetSolarMutex());
- SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr();
+ SwUnoCrsr* pUnoCrsr = this->GetCursor();
if(!pUnoCrsr)
throw uno::RuntimeException();
@@ -703,8 +707,10 @@ uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXTextPortion:
aResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_FAILURE;
//#i104499# ruby portion attributes need special handling:
if( pEntry->nWID == RES_TXTATR_CJK_RUBY &&
- ePortionType == PORTION_RUBY_START )
+ m_ePortionType == PORTION_RUBY_START )
+ {
aResult.State = beans::PropertyState_DIRECT_VALUE;
+ }
if (!bDirectValuesOnly || beans::PropertyState_DIRECT_VALUE == aResult.State)
{
// get property value
@@ -815,17 +821,20 @@ beans::PropertyState SwXTextPortion::getPropertyState(const OUString& rPropertyN
{
vos::OGuard aGuard(Application::GetSolarMutex());
beans::PropertyState eRet = beans::PropertyState_DEFAULT_VALUE;
- SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr();
- if(pUnoCrsr)
+ SwUnoCrsr* pUnoCrsr = GetCursor();
+ if (!pUnoCrsr)
+ throw uno::RuntimeException();
+
+ if (GetTextPortionType() == PORTION_RUBY_START &&
+ !rPropertyName.compareToAscii( RTL_CONSTASCII_STRINGPARAM("Ruby") ))
{
- if(GetTextPortionType() == PORTION_RUBY_START &&
- !rPropertyName.compareToAscii( RTL_CONSTASCII_STRINGPARAM("Ruby") ))
- eRet = beans::PropertyState_DIRECT_VALUE;
- else
- eRet = SwXTextCursor::GetPropertyState(*pUnoCrsr, *m_pPropSet, rPropertyName);
+ eRet = beans::PropertyState_DIRECT_VALUE;
}
else
- throw uno::RuntimeException();
+ {
+ eRet = SwXTextCursor::GetPropertyState(*pUnoCrsr, *m_pPropSet,
+ rPropertyName);
+ }
return eRet;
}
/*-- 08.03.99 09:41:47---------------------------------------------------
@@ -836,10 +845,13 @@ uno::Sequence< beans::PropertyState > SwXTextPortion::getPropertyStates(
throw( beans::UnknownPropertyException, uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
- SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr();
+ SwUnoCrsr* pUnoCrsr = GetCursor();
if(!pUnoCrsr)
throw uno::RuntimeException();
- uno::Sequence< beans::PropertyState > aRet = SwXTextCursor::GetPropertyStates(*pUnoCrsr, *m_pPropSet, rPropertyNames, SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION);
+
+ uno::Sequence< beans::PropertyState > aRet =
+ SwXTextCursor::GetPropertyStates(*pUnoCrsr, *m_pPropSet,
+ rPropertyNames, SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION);
if(GetTextPortionType() == PORTION_RUBY_START)
{
@@ -860,13 +872,11 @@ void SwXTextPortion::setPropertyToDefault(const OUString& rPropertyName)
throw( beans::UnknownPropertyException, uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
- SwUnoCrsr* pUnoCrsr = GetCrsr();
- if(pUnoCrsr)
- {
- SwXTextCursor::SetPropertyToDefault(*pUnoCrsr, *m_pPropSet, rPropertyName);
- }
- else
+ SwUnoCrsr* pUnoCrsr = GetCursor();
+ if (!pUnoCrsr)
throw uno::RuntimeException();
+
+ SwXTextCursor::SetPropertyToDefault(*pUnoCrsr, *m_pPropSet, rPropertyName);
}
/*-- 08.03.99 09:41:48---------------------------------------------------
@@ -874,33 +884,17 @@ void SwXTextPortion::setPropertyToDefault(const OUString& rPropertyName)
uno::Any SwXTextPortion::getPropertyDefault(const OUString& rPropertyName)
throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
{
+ vos::OGuard aGuard(Application::GetSolarMutex());
uno::Any aRet;
- SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr();
- if(pUnoCrsr)
- {
- aRet = SwXTextCursor::GetPropertyDefault(*pUnoCrsr, *m_pPropSet, rPropertyName);
- }
- else
+ SwUnoCrsr* pUnoCrsr = GetCursor();
+ if (!pUnoCrsr)
throw uno::RuntimeException();
+
+ aRet = SwXTextCursor::GetPropertyDefault(*pUnoCrsr, *m_pPropSet,
+ rPropertyName);
return aRet;
}
-/*-- 11.12.98 09:56:59---------------------------------------------------
- -----------------------------------------------------------------------*/
-OUString SwXTextPortion::getPresentation(sal_Bool /*bShowCommand*/) throw( uno::RuntimeException )
-{
- vos::OGuard aGuard(Application::GetSolarMutex());
- SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr();
- String sRet;
- SwFmtFld* pFmt = 0;
- if(pUnoCrsr && 0 != (pFmt = GetFldFmt()))
- {
- const SwField* pField = pFmt->GetFld();
- DBG_ERROR("bShowCommand auswerten!");
- sRet = pField->Expand();
- }
- return sRet;
-}
/*-- 11.12.98 09:56:59---------------------------------------------------
-----------------------------------------------------------------------*/
@@ -915,31 +909,31 @@ void SwXTextPortion::attach(const uno::Reference< text::XTextRange > & /*xTextRa
/*-- 11.12.98 09:57:00---------------------------------------------------
-----------------------------------------------------------------------*/
-uno::Reference< text::XTextRange > SwXTextPortion::getAnchor(void) throw( uno::RuntimeException )
+uno::Reference< text::XTextRange > SwXTextPortion::getAnchor()
+throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
uno::Reference< text::XTextRange > aRet;
- SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr();
- if(pUnoCrsr)
- aRet = new SwXTextRange(*pUnoCrsr, xParentText);
- else
+ SwUnoCrsr* pUnoCrsr = GetCursor();
+ if (!pUnoCrsr)
throw uno::RuntimeException();
+
+ aRet = new SwXTextRange(*pUnoCrsr, m_xParentText);
return aRet;
}
/*-- 11.12.98 09:57:00---------------------------------------------------
-----------------------------------------------------------------------*/
-void SwXTextPortion::dispose(void) throw( uno::RuntimeException )
+void SwXTextPortion::dispose()
+throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
- SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr();
- if(pUnoCrsr)
- {
- setString(aEmptyStr);
- pUnoCrsr->Remove(this);
- }
- else
+ SwUnoCrsr* pUnoCrsr = GetCursor();
+ if (!pUnoCrsr)
throw uno::RuntimeException();
+
+ setString(aEmptyStr);
+ pUnoCrsr->Remove(this);
}
/*-- 11.12.98 09:57:00---------------------------------------------------
@@ -949,7 +943,8 @@ void SwXTextPortion::addEventListener(const uno::Reference< lang::XEventListener
vos::OGuard aGuard(Application::GetSolarMutex());
if(!GetRegisteredIn())
throw uno::RuntimeException();
- aLstnrCntnr.AddListener(aListener);
+
+ m_ListenerContainer.AddListener(aListener);
}
/*-- 11.12.98 09:57:01---------------------------------------------------
@@ -957,7 +952,7 @@ void SwXTextPortion::addEventListener(const uno::Reference< lang::XEventListener
void SwXTextPortion::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
- if(!GetRegisteredIn() || !aLstnrCntnr.RemoveListener(aListener))
+ if (!GetRegisteredIn() || !m_ListenerContainer.RemoveListener(aListener))
throw uno::RuntimeException();
}
/* -----------------24.03.99 13:30-------------------
@@ -967,10 +962,13 @@ uno::Reference< container::XEnumeration > SwXTextPortion::createContentEnumerat
throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
- SwUnoCrsr* pUnoCrsr = GetCrsr();
+ SwUnoCrsr* pUnoCrsr = GetCursor();
if(!pUnoCrsr)
throw uno::RuntimeException();
- uno::Reference< container::XEnumeration > xRet = new SwXParaFrameEnumeration(*pUnoCrsr, PARAFRAME_PORTION_CHAR, pFrameFmt);
+
+ uno::Reference< container::XEnumeration > xRet =
+ new SwXParaFrameEnumeration(*pUnoCrsr, PARAFRAME_PORTION_CHAR,
+ m_pFrameFmt);
return xRet;
}
@@ -999,7 +997,8 @@ sal_Int64 SwXTextPortion::getSomething( const uno::Sequence< sal_Int8 >& rId )
/* -----------------24.03.99 13:30-------------------
*
* --------------------------------------------------*/
-uno::Sequence< OUString > SwXTextPortion::getAvailableServiceNames(void) throw( uno::RuntimeException )
+uno::Sequence< OUString > SwXTextPortion::getAvailableServiceNames()
+throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
uno::Sequence< OUString > aRet(1);
@@ -1010,7 +1009,8 @@ uno::Sequence< OUString > SwXTextPortion::getAvailableServiceNames(void) throw(
/* -----------------25.03.99 10:30-------------------
*
* --------------------------------------------------*/
-OUString SwXTextPortion::getImplementationName(void) throw( uno::RuntimeException )
+OUString SwXTextPortion::getImplementationName()
+throw( uno::RuntimeException )
{
return C2U("SwXTextPortion");
}
@@ -1020,7 +1020,7 @@ OUString SwXTextPortion::getImplementationName(void) throw( uno::RuntimeExceptio
sal_Bool SwXTextPortion::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
- SwUnoCrsr* pUnoCrsr = GetCrsr();
+ SwUnoCrsr* pUnoCrsr = GetCursor();
if(!pUnoCrsr)
throw uno::RuntimeException();
@@ -1032,25 +1032,24 @@ sal_Bool SwXTextPortion::supportsService(const OUString& rServiceName) throw( un
!rServiceName.compareToAscii("com.sun.star.style.ParagraphProperties") ||
!rServiceName.compareToAscii("com.sun.star.style.ParagraphPropertiesAsian") ||
!rServiceName.compareToAscii("com.sun.star.style.ParagraphPropertiesComplex"))
+ {
bRet = sal_True;
- else if(COMPARE_EQUAL == rServiceName.compareToAscii("com.sun.star.text.TextField"))
- bRet = 0 != GetFldFmt();
+ }
return bRet;
}
/* ---------------------------------------------------------------------------
---------------------------------------------------------------------------*/
-uno::Sequence< OUString > SwXTextPortion::getSupportedServiceNames(void)
- throw( uno::RuntimeException )
+uno::Sequence< OUString > SwXTextPortion::getSupportedServiceNames()
+throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
- SwUnoCrsr* pUnoCrsr = GetCrsr();
- if(!pUnoCrsr)
+ SwUnoCrsr* pUnoCrsr = GetCursor();
+ if (!pUnoCrsr)
throw uno::RuntimeException();
- sal_Bool bField = 0 != GetFldFmt();
- sal_uInt16 nCount = bField ? 8 : 7;
- uno::Sequence< OUString > aRet(nCount);
+
+ uno::Sequence< OUString > aRet(7);
OUString* pArray = aRet.getArray();
pArray[0] = C2U("com.sun.star.text.TextPortion");
pArray[1] = C2U("com.sun.star.style.CharacterProperties");
@@ -1059,8 +1058,6 @@ uno::Sequence< OUString > SwXTextPortion::getSupportedServiceNames(void)
pArray[4] = C2U("com.sun.star.style.ParagraphProperties");
pArray[5] = C2U("com.sun.star.style.ParagraphPropertiesAsian");
pArray[6] = C2U("com.sun.star.style.ParagraphPropertiesComplex");
- if(bField)
- pArray[7] = C2U("com.sun.star.text.TextField");
return aRet;
}
/*-- 11.12.98 09:57:01---------------------------------------------------
@@ -1069,34 +1066,9 @@ uno::Sequence< OUString > SwXTextPortion::getSupportedServiceNames(void)
void SwXTextPortion::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew)
{
ClientModify(this, pOld, pNew);
- if(!aFrameDepend.GetRegisteredIn())
- pFrameFmt = 0;
-}
-/* -----------------------------19.02.01 10:52--------------------------------
-
- ---------------------------------------------------------------------------*/
-SwXRubyPortion::SwXRubyPortion(const SwUnoCrsr* pPortionCrsr,
- SwTxtRuby& rAttr,
- uno::Reference< text::XText > const& rParent,
- sal_Bool bEnd ) :
- SwXTextPortion(pPortionCrsr, rParent, bEnd ? PORTION_RUBY_END : PORTION_RUBY_START )
-{
- if(!bEnd)
+ if (!m_FrameDepend.GetRegisteredIn())
{
- const SfxPoolItem& rItem = rAttr.GetAttr();
- pRubyText = new uno::Any;
- pRubyStyle = new uno::Any;
- pRubyAdjust = new uno::Any;
- pRubyIsAbove = new uno::Any;
- rItem.QueryValue(*pRubyText, MID_RUBY_TEXT);
- rItem.QueryValue(*pRubyStyle, MID_RUBY_CHARSTYLE);
- rItem.QueryValue(*pRubyAdjust, MID_RUBY_ADJUST);
- rItem.QueryValue(*pRubyIsAbove, MID_RUBY_ABOVE);
+ m_pFrameFmt = 0;
}
}
-/* -----------------------------19.02.01 10:52--------------------------------
- ---------------------------------------------------------------------------*/
-SwXRubyPortion::~SwXRubyPortion()
-{
-}
diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx
index d972329b0f52..b49816d9c9e3 100644
--- a/sw/source/core/unocore/unoportenum.cxx
+++ b/sw/source/core/unocore/unoportenum.cxx
@@ -32,30 +32,37 @@
#include "precompiled_sw.hxx"
+#include <unoport.hxx>
#include <IMark.hxx>
// --> OD 2007-10-23 #i81002#
#include <crossrefbookmark.hxx>
// <--
#include <doc.hxx>
#include <txatbase.hxx>
+#include <txtatr.hxx>
#include <ndhints.hxx>
#include <ndtxt.hxx>
#include <unocrsr.hxx>
#include <docary.hxx>
-#include <fmthbsh.hxx>
#include <tox.hxx>
#include <unoclbck.hxx>
#include <unoobj.hxx>
#include <unoredline.hxx>
+#include <unofield.hxx>
+#include <unometa.hxx>
#include <fmtanchr.hxx>
+#include <fmtrfmrk.hxx>
#include <unoidx.hxx>
#include <redline.hxx>
#include <crsskip.hxx>
#include <vos/mutex.hxx>
#include <vcl/svapp.hxx>
#include <set>
+
#include <boost/shared_ptr.hpp>
#include <boost/bind.hpp>
+#include <algorithm>
+#include <stack>
using namespace ::com::sun::star;
@@ -64,6 +71,16 @@ using namespace ::com::sun::star::text;
using ::rtl::OUString;
using namespace ::std;
+typedef ::std::pair< TextRangeList_t * const, SwTxtAttr const * const > PortionList_t;
+typedef ::std::stack< PortionList_t > PortionStack_t;
+
+static void lcl_CreatePortions(
+ TextRangeList_t & i_rPortions,
+ uno::Reference< text::XText > const& i_xParentText,
+ SwUnoCrsr* pUnoCrsr,
+ FrameDependSortList_t & i_rFrames,
+ const sal_Int32 i_nStartPos, const sal_Int32 i_nEndPos );
+
namespace
{
@@ -182,8 +199,9 @@ const uno::Sequence< sal_Int8 > & SwXTextPortionEnumeration::getUnoTunnelId()
/* -----------------------------10.03.00 18:04--------------------------------
---------------------------------------------------------------------------*/
-sal_Int64 SAL_CALL SwXTextPortionEnumeration::getSomething( const uno::Sequence< sal_Int8 >& rId )
- throw(uno::RuntimeException)
+sal_Int64 SAL_CALL SwXTextPortionEnumeration::getSomething(
+ const uno::Sequence< sal_Int8 >& rId )
+throw(uno::RuntimeException)
{
if( rId.getLength() == 16
&& 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
@@ -196,167 +214,286 @@ sal_Int64 SAL_CALL SwXTextPortionEnumeration::getSomething( const uno::Sequence<
/* -----------------------------06.04.00 16:39--------------------------------
---------------------------------------------------------------------------*/
-OUString SwXTextPortionEnumeration::getImplementationName(void) throw( RuntimeException )
+OUString SwXTextPortionEnumeration::getImplementationName()
+throw( RuntimeException )
{
return C2U("SwXTextPortionEnumeration");
}
/* -----------------------------06.04.00 16:39--------------------------------
---------------------------------------------------------------------------*/
-BOOL SwXTextPortionEnumeration::supportsService(const OUString& rServiceName) throw( RuntimeException )
+sal_Bool
+SwXTextPortionEnumeration::supportsService(const OUString& rServiceName)
+throw( RuntimeException )
{
return C2U("com.sun.star.text.TextPortionEnumeration") == rServiceName;
}
/* -----------------------------06.04.00 16:39--------------------------------
---------------------------------------------------------------------------*/
-Sequence< OUString > SwXTextPortionEnumeration::getSupportedServiceNames(void) throw( RuntimeException )
+Sequence< OUString > SwXTextPortionEnumeration::getSupportedServiceNames()
+throw( RuntimeException )
{
Sequence< OUString > aRet(1);
OUString* pArray = aRet.getArray();
pArray[0] = C2U("com.sun.star.text.TextPortionEnumeration");
return aRet;
}
+
/*-- 27.01.99 10:44:43---------------------------------------------------
-----------------------------------------------------------------------*/
SwXTextPortionEnumeration::SwXTextPortionEnumeration(
- SwPaM& rParaCrsr,
- uno::Reference< XText > xParentText,
- sal_Int32 nStart,
- sal_Int32 nEnd
- ) :
- xParent(xParentText),
- bAtEnd(sal_False),
- bFirstPortion(sal_True),
- nStartPos(nStart),
- nEndPos(nEnd)
+ SwPaM& rParaCrsr,
+ uno::Reference< XText > const & xParentText,
+ const sal_Int32 nStart,
+ const sal_Int32 nEnd )
+ : m_Portions()
{
- SwUnoCrsr* pUnoCrsr = rParaCrsr.GetDoc()->CreateUnoCrsr(*rParaCrsr.GetPoint(), sal_False);
+ SwUnoCrsr* pUnoCrsr =
+ rParaCrsr.GetDoc()->CreateUnoCrsr(*rParaCrsr.GetPoint(), sal_False);
pUnoCrsr->Add(this);
DBG_ASSERT(nEnd == -1 || (nStart <= nEnd &&
nEnd <= pUnoCrsr->Start()->nNode.GetNode().GetTxtNode()->GetTxt().Len()),
"start or end value invalid!");
- //alle Rahmen, Grafiken und OLEs suchen, die an diesem Absatz
- // AM ZEICHEN gebunden sind
- ::CollectFrameAtNode( *this, pUnoCrsr->GetPoint()->nNode,
- aFrameArr, TRUE );
- CreatePortions();
+
+ // find all frames, graphics and OLEs that are bound AT character in para
+ FrameDependSortList_t frames;
+ ::CollectFrameAtNode(*this, pUnoCrsr->GetPoint()->nNode, frames, true);
+ lcl_CreatePortions(m_Portions, xParentText, pUnoCrsr, frames, nStart, nEnd);
+}
+
+SwXTextPortionEnumeration::SwXTextPortionEnumeration(
+ SwPaM& rParaCrsr,
+ TextRangeList_t const & rPortions )
+ : m_Portions( rPortions )
+{
+ SwUnoCrsr* const pUnoCrsr =
+ rParaCrsr.GetDoc()->CreateUnoCrsr(*rParaCrsr.GetPoint(), sal_False);
+ pUnoCrsr->Add(this);
}
+
/*-- 27.01.99 10:44:44---------------------------------------------------
-----------------------------------------------------------------------*/
SwXTextPortionEnumeration::~SwXTextPortionEnumeration()
{
vos::OGuard aGuard(Application::GetSolarMutex());
- for(sal_uInt16 nFrame = aFrameArr.Count(); nFrame; )
- delete aFrameArr.GetObject( --nFrame );
- aFrameArr.Remove(0, aFrameArr.Count());
-
- if( aPortionArr.Count() )
- aPortionArr.DeleteAndDestroy(0, aPortionArr.Count() );
- SwUnoCrsr* pUnoCrsr = GetCrsr();
+ SwUnoCrsr* pUnoCrsr = GetCursor();
delete pUnoCrsr;
}
/*-- 27.01.99 10:44:44---------------------------------------------------
-----------------------------------------------------------------------*/
-sal_Bool SwXTextPortionEnumeration::hasMoreElements(void) throw( uno::RuntimeException )
+sal_Bool SwXTextPortionEnumeration::hasMoreElements()
+throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
- return aPortionArr.Count() > 0;
+
+ return (m_Portions.size() > 0) ? sal_True : sal_False;
}
/*-- 27.01.99 10:44:45---------------------------------------------------
-----------------------------------------------------------------------*/
-uno::Any SwXTextPortionEnumeration::nextElement(void)
- throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
+uno::Any SwXTextPortionEnumeration::nextElement()
+throw( container::NoSuchElementException, lang::WrappedTargetException,
+ uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
- if(!aPortionArr.Count())
+
+ if (!m_Portions.size())
throw container::NoSuchElementException();
- XTextRangeRefPtr pPortion = aPortionArr.GetObject(0);
- Any aRet(pPortion, ::getCppuType((uno::Reference<XTextRange>*)0));
- aPortionArr.Remove(0);
- delete pPortion;
- return aRet;
+
+ Any any;
+ any <<= m_Portions.front();
+ m_Portions.pop_front();
+ return any;
+}
+
+//======================================================================
+
+typedef ::std::deque< xub_StrLen > FieldMarks_t;
+
+static void
+lcl_FillFieldMarkArray(FieldMarks_t & rFieldMarks, SwUnoCrsr const & rUnoCrsr,
+ const sal_Int32 i_nStartPos)
+{
+ const SwTxtNode * const pTxtNode =
+ rUnoCrsr.GetPoint()->nNode.GetNode().GetTxtNode();
+ if (!pTxtNode) return;
+
+ const sal_Unicode fld[] = {
+ CH_TXT_ATR_FIELDSTART, CH_TXT_ATR_FIELDEND, CH_TXT_ATR_FORMELEMENT, 0 };
+ xub_StrLen pos = ::std::max(static_cast<const sal_Int32>(0), i_nStartPos);
+ while ((pos = pTxtNode->GetTxt().SearchChar(fld, pos)) != STRING_NOTFOUND)
+ {
+ rFieldMarks.push_back(pos);
+ ++pos;
+ }
}
+
+static uno::Reference<text::XTextRange>
+lcl_ExportFieldMark(
+ uno::Reference< text::XText > const & i_xParentText,
+ SwUnoCrsr * const pUnoCrsr,
+ const SwTxtNode * const pTxtNode )
+{
+ uno::Reference<text::XTextRange> xRef;
+ SwDoc* pDoc = pUnoCrsr->GetDoc();
+ //flr: maybe its a good idea to add a special hint to the hints array and rely on the hint segmentation....
+ const xub_StrLen start = pUnoCrsr->Start()->nContent.GetIndex();
+ ASSERT(pUnoCrsr->End()->nContent.GetIndex() == start,
+ "hmm --- why is this different");
+
+ pUnoCrsr->Right(1, CRSR_SKIP_CHARS, FALSE, FALSE);
+ if ( *pUnoCrsr->GetMark() == *pUnoCrsr->GetPoint() )
+ {
+ ASSERT(false, "cannot move cursor?");
+ return 0;
+ }
+
+ const sal_Unicode Char = pTxtNode->GetTxt().GetChar(start);
+ if (CH_TXT_ATR_FIELDSTART == Char)
+ {
+ ::sw::mark::IFieldmark* pFieldmark = NULL;
+ if (pDoc)
+ {
+ pFieldmark = pDoc->getIDocumentMarkAccess()->
+ getFieldmarkFor(*pUnoCrsr->GetMark());
+ }
+ SwXTextPortion* pPortion = new SwXTextPortion(
+ pUnoCrsr, i_xParentText, PORTION_FIELD_START);
+ xRef = pPortion;
+ if (pPortion && pFieldmark && pDoc)
+ pPortion->SetBookmark(new SwXFieldmark(false, pFieldmark, pDoc));
+ }
+ else if (CH_TXT_ATR_FIELDEND == Char)
+ {
+ ::sw::mark::IFieldmark* pFieldmark = NULL;
+ if (pDoc)
+ {
+ pFieldmark = pDoc->getIDocumentMarkAccess()->
+ getFieldmarkFor(*pUnoCrsr->GetMark());
+ }
+ SwXTextPortion* pPortion = new SwXTextPortion(
+ pUnoCrsr, i_xParentText, PORTION_FIELD_END);
+ xRef = pPortion;
+ if (pPortion && pFieldmark && pDoc)
+ pPortion->SetBookmark(new SwXFieldmark(false, pFieldmark, pDoc));
+ }
+ else if (CH_TXT_ATR_FORMELEMENT == Char)
+ {
+ ::sw::mark::IFieldmark* pFieldmark = NULL;
+ if (pDoc)
+ {
+ pFieldmark = pDoc->getIDocumentMarkAccess()->
+ getFieldmarkFor(*pUnoCrsr->GetMark());
+ }
+ SwXTextPortion* pPortion = new SwXTextPortion(
+ pUnoCrsr, i_xParentText, PORTION_FIELD_START_END);
+ xRef = pPortion;
+ if (pPortion && pFieldmark && pDoc)
+ pPortion->SetBookmark(new SwXFieldmark(true, pFieldmark, pDoc));
+ }
+ else
+ {
+ ASSERT(false, "no fieldmark found?");
+ }
+ return xRef;
+}
+
/* -----------------------------31.08.00 14:28--------------------------------
---------------------------------------------------------------------------*/
-void lcl_InsertRefMarkPortion(
- XTextRangeArr& rArr, SwUnoCrsr* pUnoCrsr,
- Reference<XText> const& rParent, SwTxtAttr* pAttr, BOOL bEnd)
+static Reference<XTextRange>
+lcl_CreateRefMarkPortion(
+ Reference<XText> const& xParent,
+ const SwUnoCrsr * const pUnoCrsr,
+ const SwTxtAttr & rAttr, const bool bEnd)
{
SwDoc* pDoc = pUnoCrsr->GetDoc();
- SwFmtRefMark& rRefMark = ((SwFmtRefMark&)pAttr->GetAttr());
- Reference<XTextContent> xContent = ((SwUnoCallBack*)pDoc->GetUnoCallBack())->GetRefMark(rRefMark);
- if(!xContent.is())
+ const SwFmtRefMark& rRefMark =
+ static_cast<const SwFmtRefMark&>(rAttr.GetAttr());
+ Reference<XTextContent> xContent =
+ static_cast<SwUnoCallBack*>(pDoc->GetUnoCallBack())
+ ->GetRefMark(rRefMark);
+ if (!xContent.is())
+ {
xContent = new SwXReferenceMark(pDoc, &rRefMark);
+ }
SwXTextPortion* pPortion = 0;
- if(!bEnd)
+ if (!bEnd)
{
- rArr.Insert(
- new Reference< XTextRange >(pPortion = new SwXTextPortion(pUnoCrsr, rParent, PORTION_REFMARK_START)),
- rArr.Count());
+ pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_REFMARK_START);
pPortion->SetRefMark(xContent);
- pPortion->SetCollapsed(pAttr->GetEnd() ? FALSE : TRUE);
+ pPortion->SetCollapsed(rAttr.GetEnd() ? false : true);
}
else
{
- rArr.Insert(
- new Reference< XTextRange >(pPortion = new SwXTextPortion(pUnoCrsr, rParent, PORTION_REFMARK_END)),
- rArr.Count());
+ pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_REFMARK_END);
pPortion->SetRefMark(xContent);
}
+ return pPortion;
}
+
//-----------------------------------------------------------------------------
-void lcl_InsertRubyPortion( XTextRangeArr& rArr, SwUnoCrsr* pUnoCrsr,
- Reference<XText> const& rParent, SwTxtAttr* pAttr, BOOL bEnd)
+static void
+lcl_InsertRubyPortion(
+ TextRangeList_t & rPortions,
+ Reference<XText> const& xParent,
+ const SwUnoCrsr * const pUnoCrsr,
+ const SwTxtAttr & rAttr, const sal_Bool bEnd)
{
- SwXRubyPortion* pPortion =
- new SwXRubyPortion(pUnoCrsr, *(SwTxtRuby*)pAttr, rParent, bEnd);
- rArr.Insert( new Reference< XTextRange >(pPortion), rArr.Count() );
- pPortion->SetCollapsed(pAttr->GetEnd() ? FALSE : TRUE);
+ SwXTextPortion* pPortion = new SwXTextPortion(pUnoCrsr,
+ static_cast<const SwTxtRuby&>(rAttr), xParent, bEnd);
+ rPortions.push_back(pPortion);
+ pPortion->SetCollapsed(rAttr.GetEnd() ? false : true);
}
+
//-----------------------------------------------------------------------------
-void lcl_InsertTOXMarkPortion(
- XTextRangeArr& rArr, SwUnoCrsr* pUnoCrsr, Reference<XText> const& rParent,
- SwTxtAttr* pAttr, BOOL bEnd)
+static Reference<XTextRange>
+lcl_CreateTOXMarkPortion(
+ Reference<XText> const& xParent,
+ const SwUnoCrsr * const pUnoCrsr,
+ const SwTxtAttr & rAttr, const bool bEnd)
{
SwDoc* pDoc = pUnoCrsr->GetDoc();
- SwTOXMark& rTOXMark = ((SwTOXMark&)pAttr->GetAttr());
+ const SwTOXMark& rTOXMark = static_cast<const SwTOXMark&>(rAttr.GetAttr());
Reference<XTextContent> xContent =
- ((SwUnoCallBack*)pDoc->GetUnoCallBack())->GetTOXMark(rTOXMark);
- if(!xContent.is())
- xContent = new SwXDocumentIndexMark(rTOXMark.GetTOXType(), &rTOXMark, pDoc);
+ static_cast<SwUnoCallBack*>(pDoc->GetUnoCallBack())
+ ->GetTOXMark(rTOXMark);
+ if (!xContent.is())
+ {
+ xContent = new SwXDocumentIndexMark(rTOXMark.GetTOXType(),
+ &rTOXMark, pDoc);
+ }
SwXTextPortion* pPortion = 0;
- if(!bEnd)
+ if (!bEnd)
{
- rArr.Insert(
- new Reference< XTextRange >(pPortion = new SwXTextPortion(pUnoCrsr, rParent, PORTION_TOXMARK_START)),
- rArr.Count());
+ pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_TOXMARK_START);
pPortion->SetTOXMark(xContent);
- pPortion->SetCollapsed(pAttr->GetEnd() ? FALSE : TRUE);
+ pPortion->SetCollapsed(rAttr.GetEnd() ? false : true);
}
- if(bEnd)
+ else
{
- rArr.Insert(
- new Reference< XTextRange >(pPortion = new SwXTextPortion(pUnoCrsr, rParent, PORTION_TOXMARK_END)),
- rArr.Count());
+ pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_TOXMARK_END);
pPortion->SetTOXMark(xContent);
}
+ return pPortion;
}
//-----------------------------------------------------------------------------
-void lcl_ExportBookmark(
- SwXBookmarkPortion_ImplList& rBkmArr, ULONG nIndex,
- SwUnoCrsr* pUnoCrsr, Reference<XText> & rParent, XTextRangeArr& rPortionArr)
+static void
+lcl_ExportBookmark(
+ TextRangeList_t & rPortions,
+ Reference<XText> const& xParent,
+ const SwUnoCrsr * const pUnoCrsr,
+ SwXBookmarkPortion_ImplList& rBkmArr, const ULONG nIndex)
{
for ( SwXBookmarkPortion_ImplList::iterator aIter = rBkmArr.begin(), aEnd = rBkmArr.end();
aIter != aEnd; )
@@ -371,31 +508,37 @@ void lcl_ExportBookmark(
break;
SwXTextPortion* pPortion = 0;
- if(BKM_TYPE_START == pPtr->nBkmType || BKM_TYPE_START_END == pPtr->nBkmType)
+ if ((BKM_TYPE_START == pPtr->nBkmType) ||
+ (BKM_TYPE_START_END == pPtr->nBkmType))
{
- rPortionArr.Insert(
- new Reference< XTextRange >(pPortion = new SwXTextPortion(pUnoCrsr, rParent, PORTION_BOOKMARK_START)),
- rPortionArr.Count());
+ pPortion =
+ new SwXTextPortion(pUnoCrsr, xParent, PORTION_BOOKMARK_START);
+ rPortions.push_back(pPortion);
pPortion->SetBookmark(pPtr->xBookmark);
- pPortion->SetCollapsed(BKM_TYPE_START_END == pPtr->nBkmType ? TRUE : FALSE);
+ pPortion->SetCollapsed( (BKM_TYPE_START_END == pPtr->nBkmType)
+ ? true : false);
}
- if(BKM_TYPE_END == pPtr->nBkmType)
+ if (BKM_TYPE_END == pPtr->nBkmType)
{
- rPortionArr.Insert(
- new Reference< XTextRange >(pPortion = new SwXTextPortion(pUnoCrsr, rParent, PORTION_BOOKMARK_END)),
- rPortionArr.Count());
+ pPortion =
+ new SwXTextPortion(pUnoCrsr, xParent, PORTION_BOOKMARK_END);
+ rPortions.push_back(pPortion);
pPortion->SetBookmark(pPtr->xBookmark);
}
rBkmArr.erase( aIter++ );
}
}
-void lcl_ExportSoftPageBreak(
- SwSoftPageBreakList& rBreakArr, ULONG nIndex,
- SwUnoCrsr* pUnoCrsr, Reference<XText> & rParent, XTextRangeArr& rPortionArr)
+static void
+lcl_ExportSoftPageBreak(
+ TextRangeList_t & rPortions,
+ Reference<XText> const& xParent,
+ const SwUnoCrsr * const pUnoCrsr,
+ SwSoftPageBreakList& rBreakArr, const ULONG nIndex)
{
- for ( SwSoftPageBreakList::iterator aIter = rBreakArr.begin(), aEnd = rBreakArr.end();
+ for ( SwSoftPageBreakList::iterator aIter = rBreakArr.begin(),
+ aEnd = rBreakArr.end();
aIter != aEnd; )
{
if ( nIndex > *aIter )
@@ -406,9 +549,8 @@ void lcl_ExportSoftPageBreak(
if ( nIndex < *aIter )
break;
- rPortionArr.Insert(
- new Reference< XTextRange >(new SwXTextPortion(pUnoCrsr, rParent, PORTION_SOFT_PAGEBREAK)),
- rPortionArr.Count());
+ rPortions.push_back(
+ new SwXTextPortion(pUnoCrsr, xParent, PORTION_SOFT_PAGEBREAK) );
rBreakArr.erase( aIter++ );
}
}
@@ -426,49 +568,60 @@ void lcl_ExportSoftPageBreak(
struct SwXRedlinePortion_Impl
{
- const SwRedline* pRedline;
- sal_Bool bStart;
+ const SwRedline* m_pRedline;
+ const bool m_bStart;
- SwXRedlinePortion_Impl ( const SwRedline* pRed, sal_Bool bIsStart )
- : pRedline(pRed)
- , bStart(bIsStart)
+ SwXRedlinePortion_Impl ( const SwRedline* pRed, const bool bIsStart )
+ : m_pRedline(pRed)
+ , m_bStart(bIsStart)
{
}
+
ULONG getRealIndex ()
{
- return bStart ? pRedline->Start()->nContent.GetIndex() :
- pRedline->End() ->nContent.GetIndex();
+ return m_bStart ? m_pRedline->Start()->nContent.GetIndex()
+ : m_pRedline->End() ->nContent.GetIndex();
}
};
-typedef boost::shared_ptr < SwXRedlinePortion_Impl > SwXRedlinePortion_ImplSharedPtr;
+typedef boost::shared_ptr < SwXRedlinePortion_Impl >
+ SwXRedlinePortion_ImplSharedPtr;
+
struct RedlineCompareStruct
{
const SwPosition& getPosition ( const SwXRedlinePortion_ImplSharedPtr &r )
{
- return *(r->bStart ? r->pRedline->Start() : r->pRedline->End());
+ return *(r->m_bStart ? r->m_pRedline->Start() : r->m_pRedline->End());
}
+
bool operator () ( const SwXRedlinePortion_ImplSharedPtr &r1,
const SwXRedlinePortion_ImplSharedPtr &r2 )
{
return getPosition ( r1 ) < getPosition ( r2 );
}
};
-typedef std::multiset < SwXRedlinePortion_ImplSharedPtr, RedlineCompareStruct > SwXRedlinePortion_ImplList;
+
+typedef std::multiset < SwXRedlinePortion_ImplSharedPtr, RedlineCompareStruct >
+SwXRedlinePortion_ImplList;
//-----------------------------------------------------------------------------
-Reference<XTextRange> lcl_ExportHints(SwpHints* pHints,
- XTextRangeArr& rPortionArr,
- SwUnoCrsr* pUnoCrsr,
- const Reference<XText> & rParent,
+static Reference<XTextRange>
+lcl_ExportHints(
+ PortionStack_t & rPortionStack,
+ const Reference<XText> & xParent,
+ SwUnoCrsr * const pUnoCrsr,
+ SwpHints * const pHints,
+ const sal_Int32 i_nStartPos,
+ const sal_Int32 i_nEndPos,
const xub_StrLen nCurrentIndex,
- SwTextPortionType & rePortionType,
- bool & io_rbRightMoveForbidden,
+ const bool bRightMoveForbidden,
+ bool & o_rbCursorMoved,
sal_Int32 & o_rNextAttrPosition )
{
+ // if the attribute has a dummy character, then xRef is set (except META)
+ // otherwise, the portion for the attribute is inserted into rPortions!
Reference<XTextRange> xRef;
SwDoc* pDoc = pUnoCrsr->GetDoc();
- bool bAlreadyMoved = false;
//search for special text attributes - first some ends
sal_uInt16 nEndIndex = 0;
sal_uInt16 nNextEnd = 0;
@@ -478,35 +631,88 @@ Reference<XTextRange> lcl_ExportHints(SwpHints* pHints,
{
if(pHints->GetEnd(nEndIndex)->GetEnd())
{
- SwTxtAttr* pAttr = pHints->GetEnd(nEndIndex);
- USHORT nAttrWhich = pAttr->Which();
- if(nNextEnd == nCurrentIndex &&
- ( RES_TXTATR_TOXMARK == nAttrWhich ||
- RES_TXTATR_REFMARK == nAttrWhich ||
- RES_TXTATR_CJK_RUBY == nAttrWhich))
+ SwTxtAttr * const pAttr = pHints->GetEnd(nEndIndex);
+ if (nNextEnd == nCurrentIndex)
{
- switch( nAttrWhich )
+ const USHORT nWhich( pAttr->Which() );
+ switch (nWhich)
{
case RES_TXTATR_TOXMARK:
- lcl_InsertTOXMarkPortion(
- rPortionArr, pUnoCrsr, rParent, pAttr, TRUE);
- rePortionType = PORTION_TEXT;
+ {
+ Reference<XTextRange> xTmp = lcl_CreateTOXMarkPortion(
+ xParent, pUnoCrsr, *pAttr, true);
+ rPortionStack.top().first->push_back(xTmp);
+ }
break;
case RES_TXTATR_REFMARK:
- lcl_InsertRefMarkPortion(
- rPortionArr, pUnoCrsr, rParent, pAttr, TRUE);
- rePortionType = PORTION_TEXT;
+ {
+ Reference<XTextRange> xTmp = lcl_CreateRefMarkPortion(
+ xParent, pUnoCrsr, *pAttr, true);
+ rPortionStack.top().first->push_back(xTmp);
+ }
break;
case RES_TXTATR_CJK_RUBY:
//#i91534# GetEnd() == 0 mixes the order of ruby start/end
if( *pAttr->GetEnd() == *pAttr->GetStart())
{
- lcl_InsertRubyPortion(
- rPortionArr, pUnoCrsr, rParent, pAttr, sal_False);
+ lcl_InsertRubyPortion( *rPortionStack.top().first,
+ xParent, pUnoCrsr, *pAttr, sal_False);
}
- lcl_InsertRubyPortion(
- rPortionArr, pUnoCrsr, rParent, pAttr, TRUE);
- rePortionType = PORTION_TEXT;
+ lcl_InsertRubyPortion( *rPortionStack.top().first,
+ xParent, pUnoCrsr, *pAttr, sal_True);
+ break;
+ case RES_TXTATR_META:
+ case RES_TXTATR_METAFIELD:
+ {
+ ASSERT(*pAttr->GetStart() != *pAttr->GetEnd(),
+ "empty meta?");
+ if ((i_nStartPos > 0) &&
+ (*pAttr->GetStart() < i_nStartPos))
+ {
+ // force skip pAttr and rest of attribute ends
+ // at nCurrentIndex
+ // because they are not contained in the meta pAttr
+ // and the meta pAttr itself is outside selection!
+ // (necessary for SwXMeta::createEnumeration)
+ if (*pAttr->GetStart() + 1 == i_nStartPos)
+ {
+ nEndIndex = pHints->GetEndCount() - 1;
+ }
+ break;
+ }
+ PortionList_t Top = rPortionStack.top();
+ if (Top.second != pAttr)
+ {
+ ASSERT(false, "ExportHints: stack error" );
+ }
+ else
+ {
+ TextRangeList_t *const pCurrentPortions(Top.first);
+ rPortionStack.pop();
+ SwXTextPortion * pPortion;
+ if (RES_TXTATR_META == nWhich)
+ {
+ SwXMeta * const pMeta =
+ new SwXMeta(pDoc, xParent,
+ pCurrentPortions,
+ static_cast<SwTxtMeta * const>(pAttr));
+ pPortion = new SwXTextPortion(
+ pUnoCrsr, xParent, PORTION_META);
+ pPortion->SetMeta(pMeta);
+ }
+ else
+ {
+ SwXMetaField * const pMeta =
+ new SwXMetaField(pDoc, xParent,
+ pCurrentPortions,
+ static_cast<SwTxtMeta * const>(pAttr));
+ pPortion = new SwXTextPortion(
+ pUnoCrsr, xParent, PORTION_FIELD);
+ pPortion->SetTextField(pMeta);
+ }
+ rPortionStack.top().first->push_back(pPortion);
+ }
+ }
break;
}
}
@@ -520,128 +726,126 @@ Reference<XTextRange> lcl_ExportHints(SwpHints* pHints,
while(nStartIndex < pHints->GetStartCount() &&
nCurrentIndex >= (nNextStart = (*pHints->GetStart(nStartIndex)->GetStart())))
{
- SwTxtAttr* pAttr = pHints->GetStart(nStartIndex);
+ const SwTxtAttr * const pAttr = pHints->GetStart(nStartIndex);
USHORT nAttrWhich = pAttr->Which();
- if(nNextStart == nCurrentIndex &&
- (!pAttr->GetEnd() ||
- RES_TXTATR_TOXMARK == nAttrWhich ||
- RES_TXTATR_REFMARK == nAttrWhich||
- RES_TXTATR_CJK_RUBY == nAttrWhich))
+ if (nNextStart == nCurrentIndex)
{
switch( nAttrWhich )
{
case RES_TXTATR_FIELD:
- if(!io_rbRightMoveForbidden)
+ if(!bRightMoveForbidden)
{
pUnoCrsr->Right(1,CRSR_SKIP_CHARS,FALSE,FALSE);
if( *pUnoCrsr->GetMark() == *pUnoCrsr->GetPoint() )
break;
- bAlreadyMoved = true;
- rePortionType = PORTION_FIELD;
+ SwXTextPortion* pPortion;
+ xRef = pPortion = new SwXTextPortion(
+ pUnoCrsr, xParent, PORTION_FIELD);
+ Reference<XTextField> xField =
+ CreateSwXTextField(*pDoc, pAttr->GetFld());
+ pPortion->SetTextField(xField);
}
break;
case RES_TXTATR_FLYCNT :
- if(!io_rbRightMoveForbidden)
+ if(!bRightMoveForbidden)
{
pUnoCrsr->Right(1,CRSR_SKIP_CHARS,FALSE,FALSE);
if( *pUnoCrsr->GetMark() == *pUnoCrsr->GetPoint() )
break; // Robust #i81708 content in covered cells
pUnoCrsr->Exchange();
- bAlreadyMoved = true;
- rePortionType = PORTION_FRAME;
+ xRef = new SwXTextPortion(
+ pUnoCrsr, xParent, PORTION_FRAME);
}
break;
case RES_TXTATR_FTN :
{
- if(!io_rbRightMoveForbidden)
+ if(!bRightMoveForbidden)
{
pUnoCrsr->Right(1,CRSR_SKIP_CHARS,FALSE,FALSE);
if( *pUnoCrsr->GetMark() == *pUnoCrsr->GetPoint() )
break;
SwXTextPortion* pPortion;
- xRef = pPortion = new SwXTextPortion(pUnoCrsr, rParent, PORTION_FOOTNOTE);
- Reference<XTextContent> xContent =
- Reference<XTextContent>(
- SwXFootnotes::GetObject(*pDoc, pAttr->SwTxtAttr::GetFtn()),
- UNO_QUERY);
+ xRef = pPortion = new SwXTextPortion(
+ pUnoCrsr, xParent, PORTION_FOOTNOTE);
+ Reference<XFootnote> xContent =
+ SwXFootnotes::GetObject(*pDoc, pAttr->GetFtn());
pPortion->SetFootnote(xContent);
- bAlreadyMoved = true;
- rePortionType = PORTION_TEXT;
}
}
break;
- case RES_TXTATR_SOFTHYPH :
- {
- SwXTextPortion* pPortion = 0;
- rPortionArr.Insert(
- new Reference< XTextRange >(
- pPortion = new SwXTextPortion(
- pUnoCrsr, rParent, PORTION_CONTROL_CHAR)),
- rPortionArr.Count());
- pPortion->SetControlChar(3);
- rePortionType = PORTION_TEXT;
- }
- break;
- case RES_TXTATR_HARDBLANK:
- {
- rePortionType = PORTION_CONTROL_CHAR;
- SwXTextPortion* pPortion = 0;
- rPortionArr.Insert(
- new Reference< XTextRange >(
- pPortion = new SwXTextPortion(
- pUnoCrsr, rParent, PORTION_CONTROL_CHAR)),
- rPortionArr.Count());
- const SwFmtHardBlank& rFmt = pAttr->GetHardBlank();
- if(rFmt.GetChar() == '-')
- pPortion->SetControlChar(2);//HARD_HYPHEN
- else
- pPortion->SetControlChar(4);//HARD_SPACE
- rePortionType = PORTION_TEXT;
- }
- break;
case RES_TXTATR_TOXMARK:
- lcl_InsertTOXMarkPortion(
- rPortionArr, pUnoCrsr, rParent, pAttr, FALSE);
- rePortionType = PORTION_TEXT;
- break;
case RES_TXTATR_REFMARK:
-
- if(!io_rbRightMoveForbidden || pAttr->GetEnd())
+ {
+ bool bIsPoint = !(pAttr->GetEnd());
+ if (!bRightMoveForbidden || !bIsPoint)
{
- if(!pAttr->GetEnd())
+ if (bIsPoint)
{
pUnoCrsr->Right(1,CRSR_SKIP_CHARS,FALSE,FALSE);
- bAlreadyMoved = true;
}
- lcl_InsertRefMarkPortion(
- rPortionArr, pUnoCrsr, rParent, pAttr, FALSE);
- rePortionType = PORTION_TEXT;
- if(!pAttr->GetEnd())
+ Reference<XTextRange> xTmp =
+ (RES_TXTATR_REFMARK == nAttrWhich)
+ ? lcl_CreateRefMarkPortion(
+ xParent, pUnoCrsr, *pAttr, false)
+ : lcl_CreateTOXMarkPortion(
+ xParent, pUnoCrsr, *pAttr, false);
+ if (bIsPoint) // consume CH_TXTATR!
{
- if(*pUnoCrsr->GetPoint() < *pUnoCrsr->GetMark())
- pUnoCrsr->Exchange();
+ pUnoCrsr->Normalize(FALSE);
pUnoCrsr->DeleteMark();
+ xRef = xTmp;
+ }
+ else // just insert it
+ {
+ rPortionStack.top().first->push_back(xTmp);
}
}
+ }
break;
case RES_TXTATR_CJK_RUBY:
//#i91534# GetEnd() == 0 mixes the order of ruby start/end
if(pAttr->GetEnd() && (*pAttr->GetEnd() != *pAttr->GetStart()))
{
- lcl_InsertRubyPortion(
- rPortionArr, pUnoCrsr, rParent, pAttr, FALSE);
- rePortionType = PORTION_TEXT;
+ lcl_InsertRubyPortion( *rPortionStack.top().first,
+ xParent, pUnoCrsr, *pAttr, sal_False);
}
break;
+ case RES_TXTATR_META:
+ case RES_TXTATR_METAFIELD:
+ if (*pAttr->GetStart() != *pAttr->GetEnd())
+ {
+ if (!bRightMoveForbidden)
+ {
+ pUnoCrsr->Right(1,CRSR_SKIP_CHARS,FALSE,FALSE);
+ o_rbCursorMoved = true;
+ // only if the end is included in selection!
+ if ((i_nEndPos < 0) ||
+ (*pAttr->GetEnd() <= i_nEndPos))
+ {
+ rPortionStack.push( ::std::make_pair(
+ new TextRangeList_t, pAttr ));
+ }
+ }
+ }
+ break;
+ case RES_TXTATR_AUTOFMT:
+ case RES_TXTATR_INETFMT:
+ case RES_TXTATR_CHARFMT:
+ case RES_TXTATR_UNKNOWN_CONTAINER:
+ break; // these are handled as properties of a "Text" portion
default:
- DBG_ERROR("was fuer ein Attribut?");
+ DBG_ERROR("unknown attribute");
+ break;
}
-
}
nStartIndex++;
}
- if (!bAlreadyMoved)
+ if (xRef.is()) // implies that we have moved the cursor
+ {
+ o_rbCursorMoved = true;
+ }
+ if (!o_rbCursorMoved)
{
// search for attribute changes behind the current cursor position
// break up at frames, bookmarks, redlines
@@ -666,17 +870,15 @@ Reference<XTextRange> lcl_ExportHints(SwpHints* pHints,
o_rNextAttrPosition = nNextPos;
}
}
- else
- {
- io_rbRightMoveForbidden = true;
- }
return xRef;
}
-void lcl_MoveCursor( SwUnoCrsr* pUnoCrsr,
+//-----------------------------------------------------------------------------
+void lcl_MoveCursor( SwUnoCrsr * const pUnoCrsr,
const xub_StrLen nCurrentIndex,
const sal_Int32 nNextFrameIndex, const sal_Int32 nNextPortionIndex,
- const sal_Int32 nNextAttrIndex, const sal_Int32 nEndPos )
+ const sal_Int32 nNextAttrIndex, const sal_Int32 nNextFieldMarkIndex,
+ const sal_Int32 nEndPos )
{
sal_Int32 nMovePos = pUnoCrsr->GetCntntNode()->Len();
@@ -700,26 +902,22 @@ void lcl_MoveCursor( SwUnoCrsr* pUnoCrsr,
nMovePos = nNextAttrIndex;
}
+ if ((nNextFieldMarkIndex >= 0) && (nNextFieldMarkIndex < nMovePos))
+ {
+ nMovePos = nNextFieldMarkIndex;
+ }
+
if (nMovePos > nCurrentIndex)
{
// pUnoCrsr->Right(nMovePos - nCurrentIndex);
pUnoCrsr->GetPoint()->nContent = static_cast<USHORT>(nMovePos);
}
- else if(nEndPos < 0 || nCurrentIndex < nEndPos)
- {
- // ensure proper exit: move to paragraph end
- // (this should not be necessary any more; we assert it only
- // happens when the above would move to the end of the
- // paragraph anyway)
- DBG_ASSERT(nMovePos == pUnoCrsr->GetCntntNode()->Len()||
- (nEndPos > 0 && nMovePos == nEndPos),
- "may only happen at paragraph end");
- pUnoCrsr->MovePara(fnParaCurr, fnParaEnd);
- }
}
//-----------------------------------------------------------------------------
-void lcl_FillRedlineArray(SwDoc& rDoc,SwUnoCrsr& rUnoCrsr, SwXRedlinePortion_ImplList& rRedArr )
+static void
+lcl_FillRedlineArray(SwDoc const & rDoc, SwUnoCrsr const & rUnoCrsr,
+ SwXRedlinePortion_ImplList& rRedArr )
{
const SwRedlineTbl& rRedTbl = rDoc.GetRedlineTbl();
USHORT nRedTblCount = rRedTbl.Count();
@@ -736,18 +934,21 @@ void lcl_FillRedlineArray(SwDoc& rDoc,SwUnoCrsr& rUnoCrsr, SwXRedlinePortion_Imp
const SwNodeIndex nRedNode = pRedStart->nNode;
if ( nOwnNode == nRedNode )
rRedArr.insert( SwXRedlinePortion_ImplSharedPtr (
- new SwXRedlinePortion_Impl ( pRedline, TRUE) ) );
+ new SwXRedlinePortion_Impl ( pRedline, true ) ) );
if( pRedline->HasMark() && pRedline->End()->nNode == nOwnNode )
rRedArr.insert( SwXRedlinePortion_ImplSharedPtr (
- new SwXRedlinePortion_Impl ( pRedline, FALSE) ) );
+ new SwXRedlinePortion_Impl ( pRedline, false) ) );
}
}
}
//-----------------------------------------------------------------------------
-void lcl_FillSoftPageBreakArray( SwUnoCrsr& rUnoCrsr, SwSoftPageBreakList& rBreakArr )
+static void
+lcl_FillSoftPageBreakArray(
+ SwUnoCrsr const & rUnoCrsr, SwSoftPageBreakList& rBreakArr )
{
- const SwTxtNode *pTxtNode = rUnoCrsr.GetPoint()->nNode.GetNode().GetTxtNode();
+ const SwTxtNode *pTxtNode =
+ rUnoCrsr.GetPoint()->nNode.GetNode().GetTxtNode();
if( pTxtNode )
pTxtNode->fillSoftPageBreakList( rBreakArr );
}
@@ -755,9 +956,12 @@ void lcl_FillSoftPageBreakArray( SwUnoCrsr& rUnoCrsr, SwSoftPageBreakList& rBrea
/* -----------------------------19.12.00 12:25--------------------------------
---------------------------------------------------------------------------*/
-void lcl_ExportRedline(
- SwXRedlinePortion_ImplList& rRedlineArr, ULONG nIndex,
- SwUnoCrsr* pUnoCrsr, Reference<XText> & rParent, XTextRangeArr& rPortionArr)
+static void
+lcl_ExportRedline(
+ TextRangeList_t & rPortions,
+ Reference<XText> const& xParent,
+ const SwUnoCrsr * const pUnoCrsr,
+ SwXRedlinePortion_ImplList& rRedlineArr, const ULONG nIndex)
{
// MTG: 23/11/05: We want this loop to iterate over all red lines in this
@@ -773,10 +977,8 @@ void lcl_ExportRedline(
// MTG: 23/11/05: If the elements match, and them to the list
else if ( nIndex == nRealIndex )
{
- rPortionArr.Insert(
- new Reference< XTextRange >( new SwXRedlinePortion(
- pPtr->pRedline, pUnoCrsr, rParent, pPtr->bStart)),
- rPortionArr.Count());
+ rPortions.push_back( new SwXRedlinePortion(
+ pPtr->m_pRedline, pUnoCrsr, xParent, pPtr->m_bStart) );
rRedlineArr.erase ( aIter++ );
}
// MTG: 23/11/05: If we've iterated past nIndex, exit the loop
@@ -784,29 +986,63 @@ void lcl_ExportRedline(
break;
}
}
+
/* -----------------------------19.12.00 13:09--------------------------------
---------------------------------------------------------------------------*/
-void lcl_ExportBkmAndRedline(
+static void
+lcl_ExportBkmAndRedline(
+ TextRangeList_t & rPortions,
+ Reference<XText> const & xParent,
+ const SwUnoCrsr * const pUnoCrsr,
SwXBookmarkPortion_ImplList& rBkmArr,
SwXRedlinePortion_ImplList& rRedlineArr,
SwSoftPageBreakList& rBreakArr,
- ULONG nIndex,
- SwUnoCrsr* pUnoCrsr, Reference<XText> & rParent, XTextRangeArr& rPortionArr)
+ const ULONG nIndex)
{
if (rBkmArr.size())
- lcl_ExportBookmark(rBkmArr, nIndex, pUnoCrsr, rParent, rPortionArr);
+ lcl_ExportBookmark(rPortions, xParent, pUnoCrsr, rBkmArr, nIndex);
if (rRedlineArr.size())
- lcl_ExportRedline(rRedlineArr, nIndex, pUnoCrsr, rParent, rPortionArr);
+ lcl_ExportRedline(rPortions, xParent, pUnoCrsr, rRedlineArr, nIndex);
if (rBreakArr.size())
- lcl_ExportSoftPageBreak(rBreakArr, nIndex, pUnoCrsr, rParent, rPortionArr);
+ lcl_ExportSoftPageBreak(rPortions, xParent, pUnoCrsr, rBreakArr, nIndex);
}
+
//-----------------------------------------------------------------------------
-sal_Int32 lcl_GetNextIndex(SwXBookmarkPortion_ImplList& rBkmArr,
- SwXRedlinePortion_ImplList& rRedlineArr,
- SwSoftPageBreakList& rBreakArr )
+static sal_Int32
+lcl_ExportFrames(
+ TextRangeList_t & rPortions,
+ Reference<XText> const & i_xParent,
+ SwUnoCrsr * const i_pUnoCrsr,
+ FrameDependSortList_t & i_rFrames,
+ xub_StrLen const i_nCurrentIndex)
+{
+ // find first Frame in (sorted) i_rFrames at current position
+ while (i_rFrames.size() && (i_rFrames.front().nIndex == i_nCurrentIndex))
+ // do not check for i_nEnd here; this is done implicity by lcl_MoveCursor
+ {
+ const SwModify * const pFrame =
+ i_rFrames.front().pFrameDepend->GetRegisteredIn();
+ if (pFrame) // Frame could be disposed
+ {
+ SwXTextPortion* pPortion = new SwXTextPortion(i_pUnoCrsr, i_xParent,
+ *static_cast<SwFrmFmt*>( const_cast<SwModify*>( pFrame ) ) );
+ rPortions.push_back(pPortion);
+ }
+ i_rFrames.pop_front();
+ }
+
+ return i_rFrames.size() ? i_rFrames.front().nIndex : -1;
+}
+
+//-----------------------------------------------------------------------------
+static sal_Int32
+lcl_GetNextIndex(
+ SwXBookmarkPortion_ImplList const & rBkmArr,
+ SwXRedlinePortion_ImplList const & rRedlineArr,
+ SwSoftPageBreakList const & rBreakArr )
{
sal_Int32 nRet = -1;
if(rBkmArr.size())
@@ -828,284 +1064,146 @@ sal_Int32 lcl_GetNextIndex(SwXBookmarkPortion_ImplList& rBkmArr,
}
return nRet;
};
+
//-----------------------------------------------------------------------------
-void SwXTextPortionEnumeration::CreatePortions()
+static void
+lcl_CreatePortions(
+ TextRangeList_t & i_rPortions,
+ uno::Reference< text::XText > const & i_xParentText,
+ SwUnoCrsr * const pUnoCrsr,
+ FrameDependSortList_t & i_rFrames,
+ const sal_Int32 i_nStartPos,
+ const sal_Int32 i_nEndPos )
{
- SwUnoCrsr* pUnoCrsr = GetCrsr();
+ if (!pUnoCrsr)
+ return;
+
// set the start if a selection should be exported
- if(nStartPos > 0 && pUnoCrsr->Start()->nContent.GetIndex() != nStartPos)
+ if ((i_nStartPos > 0) &&
+ (pUnoCrsr->Start()->nContent.GetIndex() != i_nStartPos))
{
- if(pUnoCrsr->HasMark())
- pUnoCrsr->DeleteMark();
+ pUnoCrsr->DeleteMark();
DBG_ASSERT(pUnoCrsr->Start()->nNode.GetNode().GetTxtNode() &&
- nStartPos <= pUnoCrsr->Start()->nNode.GetNode().GetTxtNode()->GetTxt().Len(),
- "Incorrect start position" );
- // ??? should this be nStartPos - current position ?
- pUnoCrsr->Right((xub_StrLen)nStartPos,CRSR_SKIP_CHARS,FALSE,FALSE);
+ (i_nStartPos <= pUnoCrsr->Start()->nNode.GetNode().GetTxtNode()->
+ GetTxt().Len()), "Incorrect start position" );
+ // ??? should this be i_nStartPos - current position ?
+ pUnoCrsr->Right(static_cast<xub_StrLen>(i_nStartPos),
+ CRSR_SKIP_CHARS, FALSE, FALSE);
}
- if(pUnoCrsr /*&& !bAtEnd*/)
+
+ FieldMarks_t FieldMarks;
+ SwXBookmarkPortion_ImplList Bookmarks;
+ SwXRedlinePortion_ImplList Redlines;
+ SwSoftPageBreakList SoftPageBreaks;
+
+ SwDoc * const pDoc = pUnoCrsr->GetDoc();
+ lcl_FillFieldMarkArray(FieldMarks, *pUnoCrsr, i_nStartPos);
+ lcl_FillBookmarkArray(*pDoc, *pUnoCrsr, Bookmarks);
+ lcl_FillRedlineArray(*pDoc, *pUnoCrsr, Redlines);
+ lcl_FillSoftPageBreakArray(*pUnoCrsr, SoftPageBreaks);
+
+ PortionStack_t PortionStack;
+ PortionStack.push( PortionList_t(&i_rPortions, 0) );
+
+ bool bAtEnd( false );
+ while (!bAtEnd) // every iteration consumes at least current character!
{
- SwXBookmarkPortion_ImplList aBkmArr;
- SwXRedlinePortion_ImplList aRedArr;
- SwSoftPageBreakList aBreakArr;
-
- SwDoc* pDoc = pUnoCrsr->GetDoc();
- lcl_FillRedlineArray(*pDoc, *pUnoCrsr, aRedArr);
- lcl_FillBookmarkArray(*pDoc, *pUnoCrsr, aBkmArr );
- lcl_FillSoftPageBreakArray( *pUnoCrsr, aBreakArr );
-#if OSL_DEBUG_LEVEL > 1
- for (SwXBookmarkPortion_ImplList::const_iterator aIter = aBkmArr.begin(), aEnd = aBkmArr.end();
- aIter != aEnd;
- ++aIter )
+ if (pUnoCrsr->HasMark())
{
- SwXBookmarkPortion_ImplSharedPtr pPtr = (*aIter);
+ pUnoCrsr->Normalize(FALSE);
+ pUnoCrsr->DeleteMark();
}
-#endif
- while(!bAtEnd)
+ SwTxtNode * const pTxtNode = pUnoCrsr->GetNode()->GetTxtNode();
+ if (!pTxtNode)
{
- if(pUnoCrsr->HasMark())
+ DBG_ERROR("lcl_CreatePortions: no TextNode - what now ?");
+ return;
+ }
+
+ SwpHints * const pHints = pTxtNode->GetpSwpHints();
+ const xub_StrLen nCurrentIndex =
+ pUnoCrsr->GetPoint()->nContent.GetIndex();
+ // this contains the portion which consumes the character in the
+ // text at nCurrentIndex; i.e. it must be set _once_ per iteration
+ uno::Reference< XTextRange > xRef;
+
+ SwXTextCursor::SelectPam(*pUnoCrsr, sal_True); // set mark
+
+ const sal_Int32 nFirstFrameIndex =
+ lcl_ExportFrames( *PortionStack.top().first,
+ i_xParentText, pUnoCrsr, i_rFrames, nCurrentIndex);
+
+ lcl_ExportBkmAndRedline( *PortionStack.top().first, i_xParentText,
+ pUnoCrsr, Bookmarks, Redlines, SoftPageBreaks, nCurrentIndex );
+
+ bool bCursorMoved( false );
+ sal_Int32 nNextAttrIndex = -1;
+ // #111716# the cursor must not move right at the
+ // end position of a selection!
+ bAtEnd = ((i_nEndPos >= 0) && (nCurrentIndex >= i_nEndPos))
+ || (nCurrentIndex >= pTxtNode->Len());
+ if (pHints)
+ {
+ // N.B.: side-effects nNextAttrIndex, bCursorMoved; may move cursor
+ xRef = lcl_ExportHints(PortionStack, i_xParentText, pUnoCrsr,
+ pHints, i_nStartPos, i_nEndPos, nCurrentIndex, bAtEnd,
+ bCursorMoved, nNextAttrIndex);
+ if (PortionStack.empty())
{
- if(*pUnoCrsr->GetPoint() < *pUnoCrsr->GetMark())
- pUnoCrsr->Exchange();
- pUnoCrsr->DeleteMark();
+ ASSERT(false, "CreatePortions: stack underflow");
+ return;
}
- SwNode* pNode = pUnoCrsr->GetNode();
- SwCntntNode *pCNd = pNode->GetCntntNode();
- if(!bFirstPortion && pCNd &&
- pUnoCrsr->GetPoint()->nContent == pCNd->Len())
+ }
+
+ if (!xRef.is() && !bCursorMoved)
+ {
+ if (!bAtEnd &&
+ FieldMarks.size() && (FieldMarks.front() == nCurrentIndex))
{
- //hier sollte man nie ankommen!
- bAtEnd = sal_True;
+ // moves cursor
+ xRef = lcl_ExportFieldMark(i_xParentText, pUnoCrsr, pTxtNode);
+ FieldMarks.pop_front();
}
- else
- {
- if(ND_TEXTNODE == pNode->GetNodeType())
- {
- SwTxtNode* pTxtNode = (SwTxtNode*)pNode;
- SwpHints* pHints = pTxtNode->GetpSwpHints();
- SwTextPortionType ePortionType = PORTION_TEXT;
- xub_StrLen nCurrentIndex = pUnoCrsr->GetPoint()->nContent.GetIndex();
- xub_StrLen nFirstFrameIndex = STRING_MAXLEN;
- uno::Reference< XTextRange > xRef;
- if(!pCNd->Len())
- {
- lcl_ExportBkmAndRedline(aBkmArr, aRedArr, aBreakArr, 0, pUnoCrsr, xParent, aPortionArr);
- // the paragraph is empty
- xRef = new SwXTextPortion(pUnoCrsr, xParent, ePortionType);
- // are there any frames?
- while(aFrameArr.Count())
- {
- SwDepend* pCurDepend = aFrameArr.GetObject(0);
- if(pCurDepend->GetRegisteredIn())
- {
- //the previously created portion has to be inserted here
- aPortionArr.Insert(new Reference<XTextRange>(xRef), aPortionArr.Count());
- xRef = new SwXTextPortion(pUnoCrsr, xParent,
- *(SwFrmFmt*)pCurDepend->GetRegisteredIn());
- }
- delete pCurDepend;
- aFrameArr.Remove(0);
- }
- }
- else
- {
- //falls schon Rahmen entsorgt wurden, dann raus hier
- for(sal_uInt16 nFrame = aFrameArr.Count(); nFrame; nFrame--)
- {
- SwDepend* pCurDepend = aFrameArr.GetObject(nFrame - 1);
- if(!pCurDepend->GetRegisteredIn())
- {
- delete pCurDepend;
- aFrameArr.Remove(nFrame - 1);
- }
- }
+ }
+ else
+ {
+ ASSERT(!FieldMarks.size() ||
+ (FieldMarks.front() != nCurrentIndex),
+ "fieldmark and hint with CH_TXTATR at same pos?");
+ }
- //zunaechst den ersten Frame im aFrameArr finden (bezogen auf die Position im Absatz)
- SwDepend* pFirstFrameDepend = 0;
- //Eintraege im aFrameArr sind sortiert!
- if(aFrameArr.Count())
- {
- SwDepend* pCurDepend = aFrameArr.GetObject(0);
- SwFrmFmt* pFormat = (SwFrmFmt*)pCurDepend->GetRegisteredIn();
- const SwFmtAnchor& rAnchor = pFormat->GetAnchor();
- const SwPosition* pAnchorPos = rAnchor.GetCntntAnchor();
- pFirstFrameDepend = pCurDepend;
- nFirstFrameIndex = pAnchorPos->nContent.GetIndex();
- if(nEndPos >= 0 && nFirstFrameIndex >= nEndPos)
- nFirstFrameIndex = USHRT_MAX;
- }
+ if (!bAtEnd && !xRef.is() && !bCursorMoved)
+ {
+ const sal_Int32 nNextPortionIndex =
+ lcl_GetNextIndex(Bookmarks, Redlines, SoftPageBreaks);
+ const sal_Int32 nNextFieldMarkIndex(
+ FieldMarks.size() ? FieldMarks.front() : -1);
- SwXTextCursor::SelectPam(*pUnoCrsr, sal_True);
+ lcl_MoveCursor(pUnoCrsr, nCurrentIndex,
+ nFirstFrameIndex, nNextPortionIndex, nNextAttrIndex,
+ nNextFieldMarkIndex,
+ i_nEndPos);
- //ist hier schon ein Rahmen faellig?
- if(nCurrentIndex == nFirstFrameIndex)
- {
- xRef = new SwXTextPortion(pUnoCrsr, xParent,
- *(SwFrmFmt*)pFirstFrameDepend->GetRegisteredIn());
- SwDepend* pCurDepend = aFrameArr.GetObject(0);
- delete pCurDepend;
- aFrameArr.Remove(0);
- }
- }
- if(!xRef.is())
- {
- lcl_ExportBkmAndRedline(aBkmArr, aRedArr, aBreakArr,
- nCurrentIndex, pUnoCrsr, xParent, aPortionArr);
- sal_Int32 nNextAttrIndex = -1;
- sal_Int32 nNextPortionIndex =
- lcl_GetNextIndex(aBkmArr, aRedArr, aBreakArr);
- // #111716# the cursor must not move right at the
- // end position of a selection!
- bool bRightMoveForbidden =
- ((nEndPos > 0) && (nCurrentIndex >= nEndPos));
- if (pHints)
- {
- // N.B.: side-effects bRightMoveForbidden
- // and nNextAttrIndex
- xRef = lcl_ExportHints(pHints, aPortionArr,
- pUnoCrsr, xParent, nCurrentIndex, ePortionType,
- bRightMoveForbidden, nNextAttrIndex);
- }
- if (!bRightMoveForbidden)
- {
- lcl_MoveCursor(pUnoCrsr, nCurrentIndex,
- nFirstFrameIndex, nNextPortionIndex,
- nNextAttrIndex, nEndPos);
- }
- }
- if(!xRef.is() && pUnoCrsr->HasMark() ) {
- //flr: maybe its a good idea to add a special hint to the hints array and rely on the hint segmentation....
- xub_StrLen start=pUnoCrsr->Start()->nContent.GetIndex();
- xub_StrLen end=pUnoCrsr->End()->nContent.GetIndex();
- ASSERT(start<=end, "hmm --- why is this different");
- xub_StrLen startMarkerPos=pTxtNode->GetTxt().Search(CH_TXT_ATR_FIELDSTART, start);
- xub_StrLen endMarkerPos=pTxtNode->GetTxt().Search(CH_TXT_ATR_FIELDEND, start);
- xub_StrLen formMarkerPos=pTxtNode->GetTxt().Search(CH_TXT_ATR_FORMELEMENT, start);
- xub_StrLen markerPos=STRING_LEN;
- if (startMarkerPos>=start && startMarkerPos<end)
- {
- markerPos=startMarkerPos;
- }
- if (endMarkerPos>=start && endMarkerPos<end)
- {
- if (endMarkerPos<markerPos)
- markerPos=endMarkerPos;
- }
- if (formMarkerPos>=start && formMarkerPos<end)
- {
- if (formMarkerPos<markerPos)
- markerPos=formMarkerPos;
- }
- if (markerPos<end)
- {
- if (start==markerPos)
- end = markerPos+1;
- else
- end = markerPos;
- bAtEnd = sal_False;
- pUnoCrsr->GetPoint()->nContent = end;
- }
- if (start+1==end && pTxtNode->GetTxt().GetChar(start)==CH_TXT_ATR_FIELDSTART)
- {
- ::sw::mark::IFieldmark* pFieldmark = NULL;
- if (pDoc && pUnoCrsr->GetPoint())
- pFieldmark = pDoc->getIDocumentMarkAccess()->getFieldmarkFor(*pUnoCrsr->GetPoint());
- SwXTextPortion* pPortion = NULL;
- xRef = (pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_FIELD_START));
- if (pPortion && pFieldmark && pDoc)
- pPortion->SetBookmark(new SwXFieldmark(false, pFieldmark, pDoc));
- }
- else if (start+1==end && pTxtNode->GetTxt().GetChar(start)==CH_TXT_ATR_FIELDEND)
- {
- ::sw::mark::IFieldmark* pFieldmark = NULL;
- if (pDoc && pUnoCrsr->GetPoint())
- {
- SwPosition aPos(*pUnoCrsr->GetPoint());
- aPos.nContent = markerPos;
- pFieldmark = pDoc->getIDocumentMarkAccess()->getFieldmarkFor(aPos);
- }
- SwXTextPortion* pPortion = NULL;
- xRef = (pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_FIELD_END));
- if (pPortion && pFieldmark && pDoc)
- pPortion->SetBookmark(new SwXFieldmark(false, pFieldmark, pDoc));
- }
- else if (start+1==end && pTxtNode->GetTxt().GetChar(start)==CH_TXT_ATR_FORMELEMENT)
- {
- ::sw::mark::IFieldmark* pFieldmark = NULL;
- if (pDoc && pUnoCrsr->GetPoint())
- {
- SwPosition aPos(*pUnoCrsr->GetPoint());
- aPos.nContent=markerPos;
- pFieldmark = pDoc->getIDocumentMarkAccess()->getFieldmarkFor(aPos);
- }
- SwXTextPortion* pPortion=NULL;
- xRef = (pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_FIELD_START_END));
- if(pPortion && pFieldmark && pDoc)
- pPortion->SetBookmark(new SwXFieldmark(true, pFieldmark, pDoc));
- }
- else
- {
- xRef = new SwXTextPortion(pUnoCrsr, xParent, ePortionType);
- }
- }
- if(xRef.is())
- aPortionArr.Insert(new Reference<XTextRange>(xRef), aPortionArr.Count());
- }
- else
- {
- DBG_ERROR("kein TextNode - was nun?");
- }
- }
- if(*pUnoCrsr->GetPoint() < *pUnoCrsr->GetMark())
- pUnoCrsr->Exchange();
-
- // Absatzende ?
- pNode = pUnoCrsr->GetNode();
- pCNd = pNode->GetCntntNode();
- sal_Int32 nLocalEnd = nEndPos >= 0 ? nEndPos : pCNd->Len();
- if( pCNd && pUnoCrsr->GetPoint()->nContent >= (xub_StrLen)nLocalEnd)
- {
- bAtEnd = sal_True;
- lcl_ExportBkmAndRedline(aBkmArr, aRedArr, aBreakArr, nLocalEnd,
- pUnoCrsr, xParent, aPortionArr);
- if(ND_TEXTNODE == pNode->GetNodeType())
- {
- SwTxtNode* pTxtNode = (SwTxtNode*)pNode;
- SwpHints* pHints = pTxtNode->GetpSwpHints();
- if(pHints)
- {
- SwTextPortionType ePortionType = PORTION_TEXT;
- bool bDummy = false;
- sal_Int32 nDummy = -1;
- Reference<XTextRange> xRef = lcl_ExportHints(pHints,
- aPortionArr,
- pUnoCrsr,
- xParent,
- static_cast< xub_StrLen >(nLocalEnd),
- ePortionType,
- bDummy, nDummy);
- if(xRef.is())
- aPortionArr.Insert(new Reference<XTextRange>(xRef), aPortionArr.Count());
- }
- }
- while(aFrameArr.Count())
- {
- SwDepend* pCurDepend = aFrameArr.GetObject(0);
- if(pCurDepend->GetRegisteredIn())
- {
- Reference<XTextRange> xRef = new SwXTextPortion(pUnoCrsr, xParent,
- *(SwFrmFmt*)pCurDepend->GetRegisteredIn());
- aPortionArr.Insert(new Reference<XTextRange>(xRef), aPortionArr.Count());
- }
- delete pCurDepend;
- aFrameArr.Remove(0);
- }
+ xRef = new SwXTextPortion(pUnoCrsr, i_xParentText, PORTION_TEXT);
+ }
+ else if (bAtEnd && !xRef.is() && !pTxtNode->Len())
+ {
+ // special case: for an empty paragraph, we better put out a
+ // text portion because there may be a hyperlink attribute
+ xRef = new SwXTextPortion(pUnoCrsr, i_xParentText, PORTION_TEXT);
+ }
- }
+ if (xRef.is())
+ {
+ PortionStack.top().first->push_back(xRef);
}
}
+
+ ASSERT((PortionStack.size() == 1) && !PortionStack.top().second,
+ "CreatePortions: stack error" );
}
+
/*-- 27.01.99 10:44:45---------------------------------------------------
-----------------------------------------------------------------------*/
diff --git a/sw/source/core/unocore/unoprnms.cxx b/sw/source/core/unocore/unoprnms.cxx
index 7b58a4120de7..edd0721d5b63 100644
--- a/sw/source/core/unocore/unoprnms.cxx
+++ b/sw/source/core/unocore/unoprnms.cxx
@@ -779,7 +779,8 @@ const SwPropNameTab aPropNameTab = {
/* 0734 CHAR_OVERLINE_COLOR */ {MAP_CHAR_LEN("CharOverlineColor")},
/* 0735 CHAR_OVERLINE_HAS_COLOR */ {MAP_CHAR_LEN("CharOverlineHasColor")},
/* 0736 UNO_NAME_OUTLINE_LEVEL */ {MAP_CHAR_LEN("OutlineLevel")},//#outline level,add<-zhaojianwei Outlinelevel
-/* 0737 UNO_NAME_DESCRIPTION */ {MAP_CHAR_LEN("Description")}
+/* 0737 UNO_NAME_DESCRIPTION */ {MAP_CHAR_LEN("Description")},
+/* 0738 UNO_NAME_META */ {MAP_CHAR_LEN("InContentMetadata")},
};
const SwPropNameLen& SwGetPropName( USHORT nId )
diff --git a/sw/source/core/unocore/unoredline.cxx b/sw/source/core/unocore/unoredline.cxx
index b04b8f0fdeaf..b04a7fea1fae 100644
--- a/sw/source/core/unocore/unoredline.cxx
+++ b/sw/source/core/unocore/unoredline.cxx
@@ -295,7 +295,7 @@ uno::Any SwXRedlinePortion::getPropertyValue( const OUString& rPropertyName )
{
if ( 1 < ( pNodeIdx->GetNode().EndOfSectionIndex() - pNodeIdx->GetNode().GetIndex() ) )
{
- SwUnoCrsr* pUnoCrsr = GetCrsr();
+ SwUnoCrsr* pUnoCrsr = GetCursor();
uno::Reference<text::XText> xRet = new SwXRedlineText(pUnoCrsr->GetDoc(), *pNodeIdx);
aRet <<= xRet;
}
@@ -318,7 +318,7 @@ uno::Any SwXRedlinePortion::getPropertyValue( const OUString& rPropertyName )
---------------------------------------------------------------------------*/
void SwXRedlinePortion::Validate() throw( uno::RuntimeException )
{
- SwUnoCrsr* pUnoCrsr = GetCrsr();
+ SwUnoCrsr* pUnoCrsr = GetCursor();
if(!pUnoCrsr)
throw uno::RuntimeException();
//search for the redline
diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx
index f0cbd754e02a..6fc3873db49c 100644
--- a/sw/source/core/unocore/unorefmk.cxx
+++ b/sw/source/core/unocore/unorefmk.cxx
@@ -124,7 +124,7 @@ SwXReferenceMark::~SwXReferenceMark()
/* -----------------03.11.99 14:14-------------------
--------------------------------------------------*/
-void SwXReferenceMark::InsertRefMark( SwPaM& rPam )
+void SwXReferenceMark::InsertRefMark(SwPaM& rPam, SwXTextCursor * pCursor)
{
//! in some cases when this function is called the pDoc pointer member may have become
//! invalid/deleted thus we obtain the document pointer from rPaM where it should always
@@ -134,10 +134,19 @@ void SwXReferenceMark::InsertRefMark( SwPaM& rPam )
UnoActionContext aCont(pDoc2);
SwTxtAttr* pTxtAttr = 0;
SwFmtRefMark aRefMark(sMarkName);
- SfxItemSet aSet(pDoc2->GetAttrPool(), RES_TXTATR_REFMARK, RES_TXTATR_REFMARK, 0L);
- aSet.Put(aRefMark);
+// SfxItemSet aSet(pDoc2->GetAttrPool(), RES_TXTATR_REFMARK, RES_TXTATR_REFMARK, 0L);
+// aSet.Put(aRefMark);
sal_Bool bMark = *rPam.GetPoint() != *rPam.GetMark();
- SwXTextCursor::SetCrsrAttr(rPam, aSet, 0);
+// SwXTextCursor::SetCrsrAttr(rPam, aSet, 0);
+
+ const bool bForceExpandHints( (!bMark && pCursor)
+ ? pCursor->IsAtEndOfMeta() : false );
+ const SetAttrMode nInsertFlags = (bForceExpandHints)
+ ? ( nsSetAttrMode::SETATTR_FORCEHINTEXPAND
+ | nsSetAttrMode::SETATTR_DONTEXPAND)
+ : nsSetAttrMode::SETATTR_DONTEXPAND;
+
+ pDoc2->InsertPoolItem( rPam, aRefMark, nInsertFlags );
if( bMark && *rPam.GetPoint() > *rPam.GetMark())
rPam.Exchange();
@@ -146,8 +155,10 @@ void SwXReferenceMark::InsertRefMark( SwPaM& rPam )
pTxtAttr = rPam.GetNode()->GetTxtNode()->GetTxtAttr(
rPam.GetPoint()->nContent, RES_TXTATR_REFMARK );
else
- pTxtAttr = rPam.GetNode()->GetTxtNode()->GetTxtAttr(
+ {
+ pTxtAttr = rPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt(
rPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_REFMARK );
+ }
if(pTxtAttr)
pMark = &pTxtAttr->GetRefMark();
@@ -179,7 +190,7 @@ void SwXReferenceMark::attachToRange(const uno::Reference< text::XTextRange > &
SwUnoInternalPaM aPam(*pDocument);
//das muss jetzt sal_True liefern
SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange);
- InsertRefMark(aPam);
+ InsertRefMark(aPam, dynamic_cast<SwXTextCursor*>(pCursor));
m_bIsDescriptor = sal_False;
pDoc = pDocument;
pDoc->GetUnoCallBack()->Add(this);
@@ -318,7 +329,7 @@ void SwXReferenceMark::setName(const OUString& Name_) throw( uno::RuntimeExcepti
sMarkName = sNewName;
//create a new one
- InsertRefMark( aPam );
+ InsertRefMark( aPam, 0 );
pDoc = aPam.GetDoc();
}
}
@@ -424,3 +435,1056 @@ void SwXReferenceMark::removeVetoableChangeListener(
{
}
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <unometa.hxx>
+#include <unoport.hxx>
+#include <txtatr.hxx>
+#include <fmtmeta.hxx>
+#include <docsh.hxx>
+
+//=============================================================================
+
+/******************************************************************
+ * SwXMetaText
+ ******************************************************************/
+
+class SwXMetaText
+ : public SwXText
+{
+private:
+ SwXMeta & m_rMeta;
+
+ virtual void PrepareForAttach(uno::Reference< text::XTextRange > & xRange,
+ const SwXTextRange* const pRange, const SwPaM * const pPam);
+
+ virtual bool CheckForOwnMemberMeta(const SwXTextRange* const pRange,
+ const SwPaM* const pPam, bool bAbsorb)
+ throw (::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::uno::RuntimeException);
+
+protected:
+ virtual const SwStartNode *GetStartNode() const;
+ virtual uno::Reference< text::XTextCursor >
+ createCursor() throw (uno::RuntimeException);
+
+public:
+ SwXMetaText(SwDoc & rDoc, SwXMeta & rMeta);
+
+ // XInterface
+ virtual void SAL_CALL acquire() throw()
+ { OSL_ENSURE(false, "ERROR: SwXMetaText::acquire"); }
+ virtual void SAL_CALL release() throw()
+ { OSL_ENSURE(false, "ERROR: SwXMetaText::release"); }
+
+ // XTypeProvider
+ virtual uno::Sequence< sal_Int8 > SAL_CALL
+ getImplementationId() throw (uno::RuntimeException);
+
+ // XText
+ virtual uno::Reference< text::XTextCursor > SAL_CALL
+ createTextCursor() throw (uno::RuntimeException);
+ virtual uno::Reference< text::XTextCursor > SAL_CALL
+ createTextCursorByRange(
+ const uno::Reference< text::XTextRange > & xTextPosition)
+ throw (uno::RuntimeException);
+
+};
+
+SwXMetaText::SwXMetaText(SwDoc & rDoc, SwXMeta & rMeta)
+ : SwXText(&rDoc, CURSOR_META)
+ , m_rMeta(rMeta)
+{
+}
+
+const SwStartNode *SwXMetaText::GetStartNode() const
+{
+ SwXText const * const pParent(
+ dynamic_cast<SwXText*>(m_rMeta.GetParentText().get()));
+ return (pParent) ? pParent->GetStartNode() : 0;
+}
+
+void SwXMetaText::PrepareForAttach( uno::Reference<text::XTextRange> & xRange,
+ const SwXTextRange* const pRange, const SwPaM * const pPam)
+{
+ SwPosition const* pPoint(0);
+ SwPosition const* pMark (0);
+ if (pRange)
+ {
+ ::sw::mark::IMark const& rIMark(*pRange->GetBookmark());
+ pMark = &rIMark.GetMarkPos();
+ if (rIMark.IsExpanded())
+ {
+ pMark = &rIMark.GetOtherMarkPos();
+ }
+ }
+ else if (pPam)
+ {
+ pPoint = pPam->GetPoint();
+ if (pPam->HasMark())
+ {
+ pMark = pPam->GetMark();
+ }
+ }
+ // create a new cursor to prevent modifying SwXTextRange
+ if (pPoint)
+ {
+ xRange = static_cast<text::XWordCursor*>(
+ new SwXTextCursor(&m_rMeta, *pPoint, CURSOR_META, GetDoc(), pMark));
+ }
+}
+
+bool SwXMetaText::CheckForOwnMemberMeta(const SwXTextRange* const pRange,
+ const SwPaM* const pPam, bool bAbsorb)
+ throw (::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::uno::RuntimeException)
+{
+ return m_rMeta.CheckForOwnMemberMeta(pRange, pPam, bAbsorb);
+}
+
+uno::Reference< text::XTextCursor > SwXMetaText::createCursor()
+throw (uno::RuntimeException)
+{
+ uno::Reference< text::XTextCursor > xRet;
+ if (IsValid())
+ {
+ SwTxtNode * pTxtNode;
+ xub_StrLen nMetaStart;
+ xub_StrLen nMetaEnd;
+ const bool bSuccess(
+ m_rMeta.SetContentRange(pTxtNode, nMetaStart, nMetaEnd) );
+ if (bSuccess)
+ {
+ SwPosition aPos(*pTxtNode, nMetaStart);
+ xRet = static_cast<text::XWordCursor*>(
+ new SwXTextCursor(&m_rMeta, aPos, CURSOR_META, GetDoc()));
+ }
+ }
+ return xRet;
+}
+
+uno::Sequence<sal_Int8> SAL_CALL
+SwXMetaText::getImplementationId() throw (uno::RuntimeException)
+{
+ return m_rMeta.getImplementationId();
+}
+
+// XText
+uno::Reference< text::XTextCursor > SAL_CALL
+SwXMetaText::createTextCursor() throw (uno::RuntimeException)
+{
+ return createCursor();
+}
+
+uno::Reference< text::XTextCursor > SAL_CALL
+SwXMetaText::createTextCursorByRange(
+ const uno::Reference<text::XTextRange> & xTextPosition)
+ throw (uno::RuntimeException)
+{
+ const uno::Reference<text::XTextCursor> xCursor( createCursor() );
+ xCursor->gotoRange(xTextPosition, sal_False);
+ return xCursor;
+}
+
+/******************************************************************
+ * SwXMeta
+ ******************************************************************/
+
+// the Meta has a cached list of text portions for its contents
+// this list is created by SwXTextPortionEnumeration
+// the Meta listens at the SwTxtNode and throws away the cache when it changes
+
+struct SwXMeta::Impl
+{
+ SwEventListenerContainer m_ListenerContainer;
+ ::std::auto_ptr<const TextRangeList_t> m_pTextPortions;
+ // 3 possible states: not attached, attached, disposed
+ bool m_bIsDisposed;
+ bool m_bIsDescriptor;
+ uno::Reference<text::XText> m_xParentText;
+ SwXMetaText m_Text;
+
+ Impl(SwXMeta & rThis, SwDoc & rDoc,
+ uno::Reference<text::XText> const& xParentText,
+ TextRangeList_t const * const pPortions,
+ SwTxtMeta const * const pHint)
+ : m_ListenerContainer(
+ static_cast< ::cppu::OWeakObject* >(&rThis))
+ , m_pTextPortions( pPortions )
+ , m_bIsDisposed( false )
+ , m_bIsDescriptor( 0 == pHint )
+ , m_xParentText(xParentText)
+ , m_Text(rDoc, rThis)
+ {
+ }
+};
+
+TYPEINIT1(SwXMeta, SwClient);
+
+inline const ::sw::Meta * SwXMeta::GetMeta() const
+{
+ return static_cast< const ::sw::Meta * >(GetRegisteredIn());
+}
+
+uno::Reference<text::XText> SwXMeta::GetParentText() const
+{
+ return m_pImpl->m_xParentText;
+}
+
+bool SwXMeta::SetContentRange(
+ SwTxtNode *& rpNode, xub_StrLen & rStart, xub_StrLen & rEnd ) const
+{
+ ::sw::Meta const * const pMeta( GetMeta() );
+ if (pMeta)
+ {
+ SwTxtMeta const * const pTxtAttr( pMeta->GetTxtAttr() );
+ if (pTxtAttr)
+ {
+ rpNode = pTxtAttr->GetTxtNode();
+ if (rpNode)
+ {
+ // rStart points at the first position _within_ the meta!
+ rStart = *pTxtAttr->GetStart() + 1;
+ rEnd = *pTxtAttr->GetEnd();
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+SwXMeta::SwXMeta(SwDoc *const pDoc,
+ uno::Reference<text::XText> const& xParentText,
+ TextRangeList_t * const pPortions, SwTxtMeta * const pHint)
+ : m_pImpl( new SwXMeta::Impl(*this, *pDoc, xParentText, pPortions, pHint) )
+{
+ if (pHint)
+ {
+ ::sw::Meta * const pMeta(
+ static_cast<SwFmtMeta&>(pHint->GetAttr()).GetMeta() );
+ ASSERT(pMeta, "SwXMeta: no meta?")
+ if (pMeta)
+ {
+ pMeta->Add(this);
+ }
+ }
+}
+
+bool SwXMeta::CheckForOwnMemberMeta(const SwXTextRange* const pRange,
+ const SwPaM* const pPam, bool bAbsorb)
+ throw (lang::IllegalArgumentException, uno::RuntimeException)
+{
+ ASSERT((pPam && !pRange) || (!pPam && pRange), "ERROR: pam xor range");
+ SwTxtNode * pTxtNode;
+ xub_StrLen nMetaStart;
+ xub_StrLen nMetaEnd;
+ const bool bSuccess( SetContentRange(pTxtNode, nMetaStart, nMetaEnd) );
+ ASSERT(bSuccess, "no pam?");
+ if (!bSuccess)
+ throw lang::DisposedException();
+ SwPosition const * const pStartPos( (pPam)
+ ? pPam->Start()
+ : &pRange->GetBookmark()->GetMarkStart() );
+ if (&pStartPos->nNode.GetNode() != pTxtNode)
+ {
+ throw lang::IllegalArgumentException(
+ C2U("trying to insert into a nesting text content, but start "
+ "of text range not in same paragraph as text content"),
+ 0, 0);
+ }
+ bool bForceExpandHints(false);
+ const xub_StrLen nStartPos(pStartPos->nContent.GetIndex());
+ // not <= but < because nMetaStart is behind dummy char!
+ // not >= but > because == means insert at end!
+ if ((nStartPos < nMetaStart) || (nStartPos > nMetaEnd))
+ {
+ throw lang::IllegalArgumentException(
+ C2U("trying to insert into a nesting text content, but start "
+ "of text range not inside text content"),
+ 0, 0);
+ }
+ else if (nStartPos == nMetaEnd)
+ {
+ bForceExpandHints = true;
+ }
+ const bool bHasEnd( (pPam)
+ ? pPam->HasMark()
+ : pRange->GetBookmark()->IsExpanded());
+ if (bHasEnd && bAbsorb)
+ {
+ SwPosition const * const pEndPos( (pPam)
+ ? pPam->End()
+ : &pRange->GetBookmark()->GetMarkEnd() );
+ if (&pEndPos->nNode.GetNode() != pTxtNode)
+ {
+ throw lang::IllegalArgumentException(
+ C2U("trying to insert into a nesting text content, but end "
+ "of text range not in same paragraph as text content"),
+ 0, 0);
+ }
+ const xub_StrLen nEndPos(pEndPos->nContent.GetIndex());
+ // not <= but < because nMetaStart is behind dummy char!
+ // not >= but > because == means insert at end!
+ if ((nEndPos < nMetaStart) || (nEndPos > nMetaEnd))
+ {
+ throw lang::IllegalArgumentException(
+ C2U("trying to insert into a nesting text content, but end "
+ "of text range not inside text content"),
+ 0, 0);
+ }
+ else if (nEndPos == nMetaEnd)
+ {
+ bForceExpandHints = true;
+ }
+ }
+ return bForceExpandHints;
+}
+
+
+SwXMeta::SwXMeta(SwDoc *const pDoc)
+ : m_pImpl( new SwXMeta::Impl(*this, *pDoc, 0, 0, 0) )
+{
+}
+
+SwXMeta::~SwXMeta()
+{
+}
+
+const uno::Sequence< sal_Int8 > & SwXMeta::getUnoTunnelId()
+{
+ static uno::Sequence< sal_Int8 > aSeq( ::CreateUnoTunnelId() );
+ return aSeq;
+}
+
+// XUnoTunnel
+sal_Int64 SAL_CALL
+SwXMeta::getSomething( const uno::Sequence< sal_Int8 > & i_rId )
+throw (uno::RuntimeException)
+{
+ if ( i_rId.getLength() == 16 &&
+ 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
+ i_rId.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast< sal_Int64 >(
+ reinterpret_cast< sal_IntPtr >(this) );
+ }
+ return 0;
+}
+
+// XServiceInfo
+::rtl::OUString SAL_CALL
+SwXMeta::getImplementationName() throw (uno::RuntimeException)
+{
+ return C2U("SwXMeta");
+}
+
+sal_Bool SAL_CALL
+SwXMeta::supportsService(const ::rtl::OUString& rServiceName)
+throw (uno::RuntimeException)
+{
+ return rServiceName.equalsAscii("com.sun.star.text.TextContent")
+ || rServiceName.equalsAscii("com.sun.star.text.InContentMetadata");
+}
+
+uno::Sequence< ::rtl::OUString > SAL_CALL
+SwXMeta::getSupportedServiceNames() throw (uno::RuntimeException)
+{
+ uno::Sequence< ::rtl::OUString > aRet(2);
+ aRet[0] = C2U("com.sun.star.text.TextContent");
+ aRet[1] = C2U("com.sun.star.text.InContentMetadata");
+ return aRet;
+}
+
+
+// XComponent
+void SAL_CALL
+SwXMeta::addEventListener(
+ uno::Reference< lang::XEventListener> const & xListener )
+throw (uno::RuntimeException)
+{
+ vos::OGuard g(Application::GetSolarMutex());
+
+ m_pImpl->m_ListenerContainer.AddListener(xListener);
+ if (m_pImpl->m_bIsDisposed)
+ {
+ m_pImpl->m_ListenerContainer.Disposing();
+ }
+}
+
+void SAL_CALL
+SwXMeta::removeEventListener(
+ uno::Reference< lang::XEventListener> const & xListener )
+throw (uno::RuntimeException)
+{
+ vos::OGuard g(Application::GetSolarMutex());
+
+ if (!m_pImpl->m_bIsDisposed)
+ {
+ m_pImpl->m_ListenerContainer.RemoveListener(xListener);
+ }
+}
+
+void SAL_CALL
+SwXMeta::dispose() throw (uno::RuntimeException)
+{
+ vos::OGuard g(Application::GetSolarMutex());
+
+ if (m_pImpl->m_bIsDescriptor)
+ {
+ m_pImpl->m_pTextPortions.reset();
+ m_pImpl->m_ListenerContainer.Disposing();
+ m_pImpl->m_bIsDisposed = true;
+ m_pImpl->m_Text.Invalidate();
+ }
+ else if (!m_pImpl->m_bIsDisposed)
+ {
+ SwTxtNode * pTxtNode;
+ xub_StrLen nMetaStart;
+ xub_StrLen nMetaEnd;
+ const bool bSuccess(SetContentRange(pTxtNode, nMetaStart, nMetaEnd));
+ ASSERT(bSuccess, "no pam?");
+ if (bSuccess)
+ {
+ // -1 because of CH_TXTATR
+ SwPaM aPam( *pTxtNode, nMetaStart - 1, *pTxtNode, nMetaEnd );
+ SwDoc * const pDoc( pTxtNode->GetDoc() );
+ pDoc->DeleteAndJoin( aPam );
+
+ // removal should call Modify and do the dispose
+ OSL_ENSURE(m_pImpl->m_bIsDisposed, "zombie meta");
+ }
+ }
+}
+
+
+void SAL_CALL
+SwXMeta::AttachImpl(const uno::Reference< text::XTextRange > & i_xTextRange,
+ const USHORT i_nWhich)
+throw (lang::IllegalArgumentException, uno::RuntimeException)
+{
+ vos::OGuard g(Application::GetSolarMutex());
+
+ if (m_pImpl->m_bIsDisposed)
+ {
+ throw lang::DisposedException();
+ }
+ if (!m_pImpl->m_bIsDescriptor)
+ {
+ throw uno::RuntimeException(
+ C2S("SwXMeta::attach(): already attached"),
+ static_cast< ::cppu::OWeakObject* >(this));
+ }
+
+ uno::Reference<lang::XUnoTunnel> xRangeTunnel(i_xTextRange, uno::UNO_QUERY);
+ if (!xRangeTunnel.is())
+ {
+ throw lang::IllegalArgumentException(
+ C2S("SwXMeta::attach(): argument is no XUnoTunnel"),
+ static_cast< ::cppu::OWeakObject* >(this), 0);
+ }
+ SwXTextRange * const pRange(
+ reinterpret_cast< SwXTextRange * >(
+ sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething(
+ SwXTextRange::getUnoTunnelId() ))) );
+ OTextCursorHelper * const pCursor( pRange ? 0 :
+ reinterpret_cast< OTextCursorHelper * >(
+ sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething(
+ OTextCursorHelper::getUnoTunnelId() ))) );
+ if (!pRange && !pCursor)
+ {
+ throw lang::IllegalArgumentException(
+ C2S("SwXMeta::attach(): argument not supported type"),
+ static_cast< ::cppu::OWeakObject* >(this), 0);
+ }
+
+ SwDoc * const pDoc(
+ pRange ? pRange->GetDoc() : pCursor ? pCursor->GetDoc() : 0 );
+ if (!pDoc)
+ {
+ throw lang::IllegalArgumentException(
+ C2S("SwXMeta::attach(): argument has no SwDoc"),
+ static_cast< ::cppu::OWeakObject* >(this), 0);
+ }
+
+ SwUnoInternalPaM aPam(*pDoc);
+ SwXTextRange::XTextRangeToSwPaM(aPam, i_xTextRange);
+
+ UnoActionContext aContext(pDoc);
+
+ SwXTextCursor const*const pTextCursor(
+ dynamic_cast<SwXTextCursor*>(pCursor));
+ const bool bForceExpandHints((pTextCursor)
+ ? pTextCursor->IsAtEndOfMeta() : false);
+ const SetAttrMode nInsertFlags( (bForceExpandHints)
+ ? ( nsSetAttrMode::SETATTR_FORCEHINTEXPAND
+ | nsSetAttrMode::SETATTR_DONTEXPAND)
+ : nsSetAttrMode::SETATTR_DONTEXPAND );
+
+ const ::boost::shared_ptr< ::sw::Meta> pMeta( (RES_TXTATR_META == i_nWhich)
+ ? ::boost::shared_ptr< ::sw::Meta>( new ::sw::Meta() )
+ : ::boost::shared_ptr< ::sw::Meta>(
+ pDoc->GetMetaFieldManager().makeMetaField()) );
+ SwFmtMeta meta(pMeta, i_nWhich); // this is cloned by Insert!
+ const bool bSuccess( pDoc->InsertPoolItem( aPam, meta, nInsertFlags ) );
+ SwTxtAttr * const pTxtAttr( pMeta->GetTxtAttr() );
+ if (!bSuccess)
+ {
+ throw lang::IllegalArgumentException(
+ C2S("SwXMeta::attach(): cannot create meta: range invalid?"),
+ static_cast< ::cppu::OWeakObject* >(this), 1);
+ }
+ if (!pTxtAttr)
+ {
+ ASSERT(false, "meta inserted, but has no text attribute?");
+ throw uno::RuntimeException(
+ C2S("SwXMeta::attach(): cannot create meta"),
+ static_cast< ::cppu::OWeakObject* >(this));
+ }
+
+ pMeta->Add(this);
+
+ m_pImpl->m_xParentText =
+ SwXTextRange::CreateParentXText(pDoc, *aPam.GetPoint());
+
+ m_pImpl->m_bIsDescriptor = false;
+}
+
+// XTextContent
+void SAL_CALL
+SwXMeta::attach(const uno::Reference< text::XTextRange > & i_xTextRange)
+throw (lang::IllegalArgumentException, uno::RuntimeException)
+{
+ return SwXMeta::AttachImpl(i_xTextRange, RES_TXTATR_META);
+}
+
+uno::Reference< text::XTextRange > SAL_CALL
+SwXMeta::getAnchor() throw (uno::RuntimeException)
+{
+ vos::OGuard g(Application::GetSolarMutex());
+
+ if (m_pImpl->m_bIsDisposed)
+ {
+ throw lang::DisposedException();
+ }
+ if (m_pImpl->m_bIsDescriptor)
+ {
+ throw uno::RuntimeException(
+ C2S("SwXMeta::getAnchor(): not inserted"),
+ static_cast< ::cppu::OWeakObject* >(this));
+ }
+
+ SwTxtNode * pTxtNode;
+ xub_StrLen nMetaStart;
+ xub_StrLen nMetaEnd;
+ const bool bSuccess(SetContentRange(pTxtNode, nMetaStart, nMetaEnd));
+ ASSERT(bSuccess, "no pam?");
+ if (!bSuccess)
+ {
+ throw lang::DisposedException(
+ C2S("SwXMeta::getAnchor(): not attached"),
+ static_cast< ::cppu::OWeakObject* >(this));
+ }
+
+ const SwPosition start(*pTxtNode, nMetaStart - 1); // -1 due to CH_TXTATR
+ const SwPosition end(*pTxtNode, nMetaEnd);
+ return SwXTextRange::CreateTextRangeFromPosition(
+ pTxtNode->GetDoc(), start, &end);
+}
+
+// XTextRange
+uno::Reference< text::XText > SAL_CALL
+SwXMeta::getText() throw (uno::RuntimeException)
+{
+ vos::OGuard g(Application::GetSolarMutex());
+ //TODO probably this should return outer meta in case there is nesting,
+ // but currently that is not done; would need to change at least
+ // SwXTextPortionEnumeration and SwXMeta::attach and other places where
+ // SwXMeta is constructed
+ return GetParentText();
+}
+
+uno::Reference< text::XTextRange > SAL_CALL
+SwXMeta::getStart() throw (uno::RuntimeException)
+{
+ vos::OGuard g(Application::GetSolarMutex());
+ return m_pImpl->m_Text.getStart();
+}
+
+uno::Reference< text::XTextRange > SAL_CALL
+SwXMeta::getEnd() throw (uno::RuntimeException)
+{
+ vos::OGuard g(Application::GetSolarMutex());
+ return m_pImpl->m_Text.getEnd();
+}
+
+rtl::OUString SAL_CALL
+SwXMeta::getString() throw (uno::RuntimeException)
+{
+ vos::OGuard g(Application::GetSolarMutex());
+ return m_pImpl->m_Text.getString();
+}
+
+void SAL_CALL
+SwXMeta::setString(const rtl::OUString& rString) throw (uno::RuntimeException)
+{
+ vos::OGuard g(Application::GetSolarMutex());
+ return m_pImpl->m_Text.setString(rString);
+}
+
+// XSimpleText
+uno::Reference< text::XTextCursor > SAL_CALL
+SwXMeta::createTextCursor() throw (uno::RuntimeException)
+{
+ vos::OGuard g(Application::GetSolarMutex());
+ return m_pImpl->m_Text.createTextCursor();
+}
+
+uno::Reference< text::XTextCursor > SAL_CALL
+SwXMeta::createTextCursorByRange(
+ const uno::Reference<text::XTextRange> & xTextPosition)
+ throw (uno::RuntimeException)
+{
+ vos::OGuard g(Application::GetSolarMutex());
+ return m_pImpl->m_Text.createTextCursorByRange(xTextPosition);
+}
+
+void SAL_CALL
+SwXMeta::insertString(const uno::Reference<text::XTextRange> & xRange,
+ const rtl::OUString& rString, sal_Bool bAbsorb)
+throw (uno::RuntimeException)
+{
+ vos::OGuard g(Application::GetSolarMutex());
+ return m_pImpl->m_Text.insertString(xRange, rString, bAbsorb);
+}
+
+void SAL_CALL
+SwXMeta::insertControlCharacter(const uno::Reference<text::XTextRange> & xRange,
+ sal_Int16 nControlCharacter, sal_Bool bAbsorb)
+throw (lang::IllegalArgumentException, uno::RuntimeException)
+{
+ vos::OGuard g(Application::GetSolarMutex());
+ return m_pImpl->m_Text.insertControlCharacter(xRange, nControlCharacter,
+ bAbsorb);
+}
+
+// XText
+void SAL_CALL
+SwXMeta::insertTextContent( const uno::Reference<text::XTextRange> & xRange,
+ const uno::Reference<text::XTextContent> & xContent, sal_Bool bAbsorb)
+throw (lang::IllegalArgumentException, uno::RuntimeException)
+{
+ vos::OGuard g(Application::GetSolarMutex());
+ return m_pImpl->m_Text.insertTextContent(xRange, xContent, bAbsorb);
+}
+
+void SAL_CALL
+SwXMeta::removeTextContent(
+ const uno::Reference< text::XTextContent > & xContent)
+ throw (container::NoSuchElementException, uno::RuntimeException)
+{
+ vos::OGuard g(Application::GetSolarMutex());
+ return m_pImpl->m_Text.removeTextContent(xContent);
+}
+
+// XElementAccess
+uno::Type SAL_CALL
+SwXMeta::getElementType() throw (uno::RuntimeException)
+{
+ return text::XTextRange::static_type();
+}
+
+sal_Bool SAL_CALL
+SwXMeta::hasElements() throw (uno::RuntimeException)
+{
+ vos::OGuard g(Application::GetSolarMutex());
+
+ return GetRegisteredIn() ? sal_True : sal_False;
+}
+
+// XEnumerationAccess
+uno::Reference< container::XEnumeration > SAL_CALL
+SwXMeta::createEnumeration() throw (uno::RuntimeException)
+{
+ vos::OGuard g(Application::GetSolarMutex());
+
+ if (m_pImpl->m_bIsDisposed)
+ {
+ throw lang::DisposedException();
+ }
+ if (m_pImpl->m_bIsDescriptor)
+ {
+ throw uno::RuntimeException(
+ C2S("getAnchor(): not inserted"),
+ static_cast< ::cppu::OWeakObject* >(this));
+ }
+
+ SwTxtNode * pTxtNode;
+ xub_StrLen nMetaStart;
+ xub_StrLen nMetaEnd;
+ const bool bSuccess(SetContentRange(pTxtNode, nMetaStart, nMetaEnd));
+ ASSERT(bSuccess, "no pam?");
+ if (!bSuccess)
+ throw lang::DisposedException();
+
+ SwPaM aPam(*pTxtNode, nMetaStart);
+
+ if (!m_pImpl->m_pTextPortions.get())
+ {
+ return new SwXTextPortionEnumeration(
+ aPam, GetParentText(), nMetaStart, nMetaEnd);
+ }
+ else // cached!
+ {
+ return new SwXTextPortionEnumeration(aPam, *m_pImpl->m_pTextPortions);
+ }
+}
+
+
+// MetadatableMixin
+::sfx2::Metadatable* SwXMeta::GetCoreObject()
+{
+ return const_cast< ::sw::Meta * >(GetMeta());
+}
+
+uno::Reference<frame::XModel> SwXMeta::GetModel()
+{
+ ::sw::Meta const * const pMeta( GetMeta() );
+ if (pMeta)
+ {
+ SwTxtNode const * const pTxtNode( pMeta->GetTxtNode() );
+ if (pTxtNode)
+ {
+ SwDocShell const * const pShell(pTxtNode->GetDoc()->GetDocShell());
+ return (pShell) ? pShell->GetModel() : 0;
+ }
+ }
+ return 0;
+}
+
+// SwModify
+void SwXMeta::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew )
+{
+ m_pImpl->m_pTextPortions.reset(); // throw away cache (SwTxtNode changed)
+
+ ClientModify(this, pOld, pNew);
+
+ if (!GetRegisteredIn()) // removed => dispose
+ {
+ m_pImpl->m_ListenerContainer.Disposing();
+ m_pImpl->m_bIsDisposed = true;
+ m_pImpl->m_Text.Invalidate();
+ }
+}
+
+
+/******************************************************************
+ * SwXMetaField
+ ******************************************************************/
+
+inline const ::sw::MetaField * SwXMetaField::GetMetaField() const
+{
+ return static_cast< const ::sw::MetaField * >(GetRegisteredIn());
+}
+
+SwXMetaField::SwXMetaField(SwDoc *const pDoc,
+ uno::Reference<text::XText> const& xParentText,
+ TextRangeList_t * const pPortions, SwTxtMeta * const pHint)
+ : SwXMetaFieldBaseClass(pDoc, xParentText, pPortions, pHint)
+{
+ ASSERT(!pHint || RES_TXTATR_METAFIELD == pHint->Which(),
+ "SwXMetaField created for wrong hint!");
+}
+
+SwXMetaField::SwXMetaField(SwDoc *const pDoc)
+ : SwXMetaFieldBaseClass(pDoc)
+{
+}
+
+SwXMetaField::~SwXMetaField()
+{
+}
+
+// XServiceInfo
+::rtl::OUString SAL_CALL
+SwXMetaField::getImplementationName() throw (uno::RuntimeException)
+{
+ return C2U("SwXMetaField");
+}
+
+sal_Bool SAL_CALL
+SwXMetaField::supportsService(const ::rtl::OUString& rServiceName)
+throw (uno::RuntimeException)
+{
+ return rServiceName.equalsAscii("com.sun.star.text.TextContent")
+ || rServiceName.equalsAscii("com.sun.star.text.TextField")
+ || rServiceName.equalsAscii("com.sun.star.text.textfield.MetadataField");
+}
+
+uno::Sequence< ::rtl::OUString > SAL_CALL
+SwXMetaField::getSupportedServiceNames() throw (uno::RuntimeException)
+{
+ uno::Sequence< ::rtl::OUString > aRet(3);
+ aRet[0] = C2U("com.sun.star.text.TextContent");
+ aRet[1] = C2U("com.sun.star.text.TextField");
+ aRet[2] = C2U("com.sun.star.text.textfield.MetadataField");
+ return aRet;
+}
+
+// XComponent
+void SAL_CALL
+SwXMetaField::addEventListener(
+ uno::Reference< lang::XEventListener> const & xListener )
+throw (uno::RuntimeException)
+{
+ return SwXMeta::addEventListener(xListener);
+}
+
+void SAL_CALL
+SwXMetaField::removeEventListener(
+ uno::Reference< lang::XEventListener> const & xListener )
+throw (uno::RuntimeException)
+{
+ return SwXMeta::removeEventListener(xListener);
+}
+
+void SAL_CALL
+SwXMetaField::dispose() throw (uno::RuntimeException)
+{
+ return SwXMeta::dispose();
+}
+
+// XTextContent
+void SAL_CALL
+SwXMetaField::attach(const uno::Reference< text::XTextRange > & i_xTextRange)
+throw (lang::IllegalArgumentException, uno::RuntimeException)
+{
+ return SwXMeta::AttachImpl(i_xTextRange, RES_TXTATR_METAFIELD);
+}
+
+uno::Reference< text::XTextRange > SAL_CALL
+SwXMetaField::getAnchor() throw (uno::RuntimeException)
+{
+ return SwXMeta::getAnchor();
+}
+
+// XPropertySet
+uno::Reference< beans::XPropertySetInfo > SAL_CALL
+SwXMetaField::getPropertySetInfo() throw (uno::RuntimeException)
+{
+ vos::OGuard g(Application::GetSolarMutex());
+
+ static uno::Reference< beans::XPropertySetInfo > xRef(
+ aSwMapProvider.GetPropertySet(PROPERTY_MAP_METAFIELD)
+ ->getPropertySetInfo() );
+ return xRef;
+}
+
+void SAL_CALL
+SwXMetaField::setPropertyValue(
+ const ::rtl::OUString& rPropertyName, const uno::Any& rValue)
+throw (beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ vos::OGuard g(Application::GetSolarMutex());
+
+ ::sw::MetaField * const pMeta(
+ const_cast< ::sw::MetaField * >(GetMetaField()) );
+ if (!pMeta)
+ throw lang::DisposedException();
+
+ if (rPropertyName.equalsAscii("NumberFormat"))
+ {
+ sal_Int32 nNumberFormat(0);
+ if (rValue >>= nNumberFormat)
+ {
+ pMeta->SetNumberFormat(static_cast<sal_uInt32>(nNumberFormat));
+ }
+ }
+ else if (rPropertyName.equalsAscii("IsFixedLanguage"))
+ {
+ bool b(false);
+ if (rValue >>= b)
+ {
+ pMeta->SetIsFixedLanguage(b);
+ }
+ }
+ else
+ {
+ throw beans::UnknownPropertyException();
+ }
+}
+
+uno::Any SAL_CALL
+SwXMetaField::getPropertyValue(const ::rtl::OUString& rPropertyName)
+throw (beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ vos::OGuard g(Application::GetSolarMutex());
+
+ ::sw::MetaField const * const pMeta( GetMetaField() );
+ if (!pMeta)
+ throw lang::DisposedException();
+
+ uno::Any any;
+
+ if (rPropertyName.equalsAscii("NumberFormat"))
+ {
+ const ::rtl::OUString text( getPresentation(sal_False) );
+ any <<= static_cast<sal_Int32>(pMeta->GetNumberFormat(text));
+ }
+ else if (rPropertyName.equalsAscii("IsFixedLanguage"))
+ {
+ any <<= pMeta->IsFixedLanguage();
+ }
+ else
+ {
+ throw beans::UnknownPropertyException();
+ }
+
+ return any;
+}
+
+void SAL_CALL
+SwXMetaField::addPropertyChangeListener(
+ const ::rtl::OUString& /*rPropertyName*/,
+ const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
+throw (beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ OSL_ENSURE(false,
+ "SwXMetaField::addPropertyChangeListener(): not implemented");
+}
+
+void SAL_CALL
+SwXMetaField::removePropertyChangeListener(
+ const ::rtl::OUString& /*rPropertyName*/,
+ const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
+throw (beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ OSL_ENSURE(false,
+ "SwXMetaField::removePropertyChangeListener(): not implemented");
+}
+
+void SAL_CALL
+SwXMetaField::addVetoableChangeListener(
+ const ::rtl::OUString& /*rPropertyName*/,
+ const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
+throw (beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ OSL_ENSURE(false,
+ "SwXMetaField::addVetoableChangeListener(): not implemented");
+}
+
+void SAL_CALL
+SwXMetaField::removeVetoableChangeListener(
+ const ::rtl::OUString& /*rPropertyName*/,
+ const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
+throw (beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ OSL_ENSURE(false,
+ "SwXMetaField::removeVetoableChangeListener(): not implemented");
+}
+
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
+#include <com/sun/star/rdf/Statement.hpp>
+#include <com/sun/star/rdf/URI.hpp>
+#include <com/sun/star/rdf/URIs.hpp>
+#include <com/sun/star/rdf/XLiteral.hpp>
+#include <com/sun/star/rdf/XRepositorySupplier.hpp>
+#include <comphelper/processfactory.hxx>
+
+static uno::Reference<rdf::XURI> const&
+lcl_getURI(const bool bPrefix)
+{
+ static uno::Reference< uno::XComponentContext > xContext(
+ ::comphelper::getProcessComponentContext());
+ static uno::Reference< rdf::XURI > xOdfPrefix(
+ rdf::URI::createKnown(xContext, rdf::URIs::ODF_PREFIX),
+ uno::UNO_SET_THROW);
+ static uno::Reference< rdf::XURI > xOdfSuffix(
+ rdf::URI::createKnown(xContext, rdf::URIs::ODF_SUFFIX),
+ uno::UNO_SET_THROW);
+ return (bPrefix) ? xOdfPrefix : xOdfSuffix;
+}
+
+static ::rtl::OUString
+lcl_getPrefixOrSuffix(
+ uno::Reference<rdf::XRepository> const & xRepository,
+ uno::Reference<rdf::XResource> const & xMetaField,
+ uno::Reference<rdf::XURI> const & xPredicate)
+{
+ const uno::Reference<container::XEnumeration> xEnum(
+ xRepository->getStatements(xMetaField, xPredicate, 0),
+ uno::UNO_SET_THROW);
+ while (xEnum->hasMoreElements()) {
+ rdf::Statement stmt;
+ if (!(xEnum->nextElement() >>= stmt)) {
+ throw uno::RuntimeException();
+ }
+ const uno::Reference<rdf::XLiteral> xObject(stmt.Object,
+ uno::UNO_QUERY);
+ if (!xObject.is()) continue;
+ if (xEnum->hasMoreElements()) {
+ OSL_TRACE("ignoring other odf:Prefix/odf:Suffix statements");
+ }
+ return xObject->getValue();
+ }
+ return ::rtl::OUString();
+}
+
+void
+getPrefixAndSuffix(
+ const uno::Reference<frame::XModel>& xModel,
+ const uno::Reference<rdf::XMetadatable>& xMetaField,
+ ::rtl::OUString *const o_pPrefix, ::rtl::OUString *const o_pSuffix)
+{
+ try {
+ const uno::Reference<rdf::XRepositorySupplier> xRS(
+ xModel, uno::UNO_QUERY_THROW);
+ const uno::Reference<rdf::XRepository> xRepo(
+ xRS->getRDFRepository(), uno::UNO_SET_THROW);
+ const uno::Reference<rdf::XResource> xMeta(
+ xMetaField, uno::UNO_QUERY_THROW);
+ if (o_pPrefix)
+ {
+ *o_pPrefix = lcl_getPrefixOrSuffix(xRepo, xMeta, lcl_getURI(true));
+ }
+ if (o_pSuffix)
+ {
+ *o_pSuffix = lcl_getPrefixOrSuffix(xRepo, xMeta, lcl_getURI(false));
+ }
+ } catch (uno::RuntimeException &) {
+ throw;
+ } catch (uno::Exception & e) {
+ throw lang::WrappedTargetRuntimeException(
+ ::rtl::OUString::createFromAscii("getPrefixAndSuffix: exception"),
+ 0, uno::makeAny(e));
+ }
+}
+
+// XTextField
+::rtl::OUString SAL_CALL
+SwXMetaField::getPresentation(sal_Bool bShowCommand)
+throw (uno::RuntimeException)
+{
+ vos::OGuard g(Application::GetSolarMutex());
+
+ if (bShowCommand)
+ {
+//FIXME ?
+ return ::rtl::OUString();
+ }
+ else
+ {
+ // getString should check if this is invalid
+ const ::rtl::OUString content( this->getString() );
+ ::rtl::OUString prefix;
+ ::rtl::OUString suffix;
+ getPrefixAndSuffix(GetModel(), this, &prefix, &suffix);
+ return prefix + content + suffix;
+ }
+}
+
diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx
index 529f36294fca..1308c6ad7d3e 100644
--- a/sw/source/core/unocore/unosect.cxx
+++ b/sw/source/core/unocore/unosect.cxx
@@ -461,7 +461,7 @@ void SwXTextSection::attachToRange(const uno::Reference< text::XTextRange > & xT
if (pProps->aPassword.getLength() > 0)
aSect.SetPasswd(pProps->aPassword);
- pRet = pDoc->Insert( aPam, aSect, aSet.Count() ? &aSet : 0 );
+ pRet = pDoc->InsertSwSection( aPam, aSect, aSet.Count() ? &aSet : 0 );
// now create the client
m_refCount++;
// keep block to remove Reference before the refcount is decremented
diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx
index c00c21f5494e..56e3cbacd822 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -45,6 +45,7 @@
#include <unoidx.hxx>
#include <unoframe.hxx>
#include <unofield.hxx>
+#include <unometa.hxx>
#include <unodraw.hxx>
#include <unoredline.hxx>
#include <unomap.hxx>
@@ -58,7 +59,6 @@
#include <swundo.hxx>
#include <section.hxx>
#include <IMark.hxx>
-#include <fmthbsh.hxx>
#include <fmtanchr.hxx>
#include <crsskip.hxx>
#include <ndtxt.hxx>
@@ -77,6 +77,21 @@ const sal_Char cInvalidObject[] = "this object is invalid";
-----------------------------------------------------------------------*/
+void SwXText::PrepareForAttach( ::com::sun::star::uno::Reference<
+ ::com::sun::star::text::XTextRange > &,
+ const SwXTextRange* const, const SwPaM * const)
+{
+}
+
+bool SwXText::CheckForOwnMemberMeta(const SwXTextRange* const,
+ const SwPaM* const, bool)
+ throw (::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::uno::RuntimeException)
+{
+ ASSERT(CURSOR_META != eCrsrType, "should not be called!");
+ return false;
+}
+
const SwStartNode *SwXText::GetStartNode() const
{
return GetDoc()->GetNodes().GetEndOfContent().StartOfSectionNode();
@@ -85,12 +100,12 @@ const SwStartNode *SwXText::GetStartNode() const
uno::Reference< text::XTextCursor > SwXText::createCursor() throw (uno::RuntimeException)
{
uno::Reference< text::XTextCursor > xRet;
- OUString sRet;
if(IsValid())
{
SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent();
SwPosition aPos(rNode);
- xRet = (text::XWordCursor*)new SwXTextCursor(this, aPos, GetTextType(), GetDoc());
+ xRet = static_cast<text::XWordCursor*>(
+ new SwXTextCursor(this, aPos, GetTextType(), GetDoc()));
xRet->gotoStart(sal_False);
}
return xRet;
@@ -278,12 +293,41 @@ void SwXText::insertString(const uno::Reference< text::XTextRange >& xTextRange,
if(!pOwnStartNode || pOwnStartNode != pTmp)
throw uno::RuntimeException();
}
+ bool bForceExpandHints( false );
+ if (CURSOR_META == eCrsrType)
+ {
+ try
+ {
+ bForceExpandHints = CheckForOwnMemberMeta(
+ pRange, (pCursor) ? pCursor->GetPaM() : 0, bAbsorb);
+ }
+ catch (lang::IllegalArgumentException & iae)
+ {
+ // stupid method not allowed to throw iae
+ throw uno::RuntimeException(iae.Message, 0);
+ }
+ }
if(bAbsorb)
{
//!! scan for CR characters and inserting the paragraph breaks
//!! has to be done in the called function.
//!! Implemented in SwXTextRange::DeleteAndInsert
- xTextRange->setString(aString);
+ if (pCursor)
+ {
+ SwXTextCursor * const pTextCursor( dynamic_cast<SwXTextCursor*>(pCursor) );
+ if (pTextCursor)
+ {
+ pTextCursor->DeleteAndInsert(aString, bForceExpandHints);
+ }
+ else
+ {
+ xTextRange->setString(aString);
+ }
+ }
+ else
+ {
+ pRange->DeleteAndInsert(aString, bForceExpandHints);
+ }
}
else
{
@@ -294,10 +338,11 @@ void SwXText::insertString(const uno::Reference< text::XTextRange >& xTextRange,
? pCursor->GetPaM()->Start()
: &pRange->GetBookmark()->GetMarkStart();
SwPaM aInsertPam(*pPos);
- sal_Bool bGroupUndo = GetDoc()->DoesGroupUndo();
+ const sal_Bool bGroupUndo = GetDoc()->DoesGroupUndo();
GetDoc()->DoGroupUndo(sal_False);
- SwUnoCursorHelper::DocInsertStringSplitCR(*GetDoc(), aInsertPam, aString);
+ SwUnoCursorHelper::DocInsertStringSplitCR(
+ *GetDoc(), aInsertPam, aString, bForceExpandHints );
GetDoc()->DoGroupUndo(bGroupUndo);
}
}
@@ -316,15 +361,29 @@ void SwXText::insertControlCharacter(const uno::Reference< text::XTextRange > &
throw( lang::IllegalArgumentException, uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
- if(GetDoc() && xTextRange.is())
+ if (!xTextRange.is())
+ throw lang::IllegalArgumentException();
+ if (GetDoc())
{
SwUnoInternalPaM aPam(*GetDoc());
if(SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange))
{
+ const bool bForceExpandHints(
+ CheckForOwnMemberMeta( 0, &aPam, bAbsorb) );
+
+ const enum IDocumentContentOperations::InsertFlags nInsertFlags =
+ (bForceExpandHints)
+ ? static_cast<IDocumentContentOperations::InsertFlags>(
+ IDocumentContentOperations::INS_FORCEHINTEXPAND |
+ IDocumentContentOperations::INS_EMPTYEXPAND)
+ : IDocumentContentOperations::INS_EMPTYEXPAND;
+
//Steuerzeichen einfuegen
SwPaM aTmp(*aPam.Start());
if(bAbsorb && aPam.HasMark())
+ {
pDoc->DeleteAndJoin(aPam);
+ }
sal_Unicode cIns = 0;
switch( nControlCharacter )
@@ -367,7 +426,9 @@ void SwXText::insertControlCharacter(const uno::Reference< text::XTextRange > &
case text::ControlCharacter::HARD_SPACE: cIns = CHAR_HARDBLANK; break;
}
if( cIns )
- pDoc->Insert( aTmp, cIns );
+ {
+ pDoc->InsertString( aTmp, cIns, nInsertFlags );
+ }
if(bAbsorb)
{
@@ -476,9 +537,9 @@ void SwXText::insertTextContent(const uno::Reference< text::XTextRange > & xRang
::sw::mark::IMark const * const pBkmk = pRange->GetBookmark();
pSrcNode = &pBkmk->GetMarkPos().nNode.GetNode();
}
- else if (pPortion && pPortion->GetCrsr())
+ else if (pPortion && pPortion->GetCursor())
{
- pSrcNode = pPortion->GetCrsr()->GetNode();
+ pSrcNode = pPortion->GetCursor()->GetNode();
}
else if (pText)
{
@@ -511,9 +572,12 @@ void SwXText::insertTextContent(const uno::Reference< text::XTextRange > & xRang
aRunException.Message = C2U("text interface and cursor not related");
throw aRunException;
}
+
+ const bool bForceExpandHints( CheckForOwnMemberMeta(
+ pRange, (pCursor) ? pCursor->GetPaM() : 0, bAbsorb) );
+
// Sonderbehandlung fuer Contents, die den Range nicht ersetzen, sonder darueber gelegt werden
// Bookmarks, IndexEntry
- sal_Bool bAttribute = sal_False;
uno::Reference<lang::XUnoTunnel> xContentTunnel( xContent, uno::UNO_QUERY);
if(!xContentTunnel.is())
{
@@ -529,8 +593,12 @@ void SwXText::insertTextContent(const uno::Reference< text::XTextRange > & xRang
sal::static_int_cast< sal_IntPtr >( xContentTunnel->getSomething( SwXBookmark::getUnoTunnelId()) ));
SwXReferenceMark* pReferenceMark = reinterpret_cast< SwXReferenceMark * >(
sal::static_int_cast< sal_IntPtr >( xContentTunnel->getSomething( SwXReferenceMark::getUnoTunnelId()) ));
+ SwXMeta *const pMeta = reinterpret_cast< SwXMeta* >(
+ sal::static_int_cast< sal_IntPtr >(
+ xContentTunnel->getSomething( SwXMeta::getUnoTunnelId())));
- bAttribute = pBookmark || pDocumentIndexMark || pSection || pReferenceMark;
+ const bool bAttribute = pBookmark || pDocumentIndexMark
+ || pSection || pReferenceMark || pMeta;
if(bAbsorb && !bAttribute)
{
@@ -542,6 +610,12 @@ void SwXText::insertTextContent(const uno::Reference< text::XTextRange > & xRang
xTempRange = xRange;
else
xTempRange = xRange->getStart();
+ if (bForceExpandHints)
+ {
+ // if necessary, replace xTempRange with a new SwXTextCursor
+ PrepareForAttach(xTempRange, pRange,
+ (pCursor) ? pCursor->GetPaM() : 0);
+ }
xContent->attach(xTempRange);
}
else
@@ -582,7 +656,7 @@ void SwXText::insertTextContentBefore(
if(!pPara || !pPara->IsDescriptor() || !xSuccessor.is())
throw lang::IllegalArgumentException();
- sal_Bool bRet = FALSE;
+ sal_Bool bRet = sal_False;
SwXTextSection* pXSection = SwXTextSection::GetImplementation( xSuccessor );
SwXTextTable* pXTable = SwXTextTable::GetImplementation(xSuccessor );
SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0;
@@ -636,7 +710,7 @@ void SwXText::insertTextContentAfter(
SwXTextSection* pXSection = SwXTextSection::GetImplementation( xPredecessor );
SwXTextTable* pXTable = SwXTextTable::GetImplementation(xPredecessor );
SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0;
- sal_Bool bRet = FALSE;
+ sal_Bool bRet = sal_False;
if(pTableFmt && pTableFmt->GetDoc() == GetDoc())
{
SwTable* pTable = SwTable::FindTable( pTableFmt );
@@ -680,7 +754,7 @@ void SwXText::removeTextContentBefore(
throw aRuntime;
}
- sal_Bool bRet = FALSE;
+ sal_Bool bRet = sal_False;
SwXTextSection* pXSection = SwXTextSection::GetImplementation( xSuccessor );
SwXTextTable* pXTable = SwXTextTable::GetImplementation( xSuccessor );
SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0;
@@ -727,7 +801,7 @@ void SwXText::removeTextContentAfter(const uno::Reference< text::XTextContent>&
throw aRuntime;
}
- sal_Bool bRet = FALSE;
+ sal_Bool bRet = sal_False;
SwXTextSection* pXSection = SwXTextSection::GetImplementation( xPredecessor );
SwXTextTable* pXTable = SwXTextTable::GetImplementation(xPredecessor );
SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0;
@@ -818,10 +892,8 @@ uno::Reference< text::XTextRange > SwXText::getEnd(void) throw( uno::RuntimeExc
aRuntime.Message = C2U(cInvalidObject);
throw aRuntime;
}
- else
- xRef->gotoEnd(sal_False);
- uno::Reference< text::XTextRange > xRet(xRef, uno::UNO_QUERY);;
-
+ xRef->gotoEnd(sal_False);
+ uno::Reference< text::XTextRange > xRet(xRef, uno::UNO_QUERY);
return xRet;
}
/*-- 09.12.98 12:43:29---------------------------------------------------
@@ -856,6 +928,7 @@ void SwXText::setString(const OUString& aString) throw( uno::RuntimeException )
GetDoc()->StartUndo(UNDO_START, NULL);
//insert an empty paragraph at the start and at the end to ensure that
//all tables and sections can be removed by the selecting text::XTextCursor
+ if (CURSOR_META != eCrsrType)
{
SwPosition aStartPos(*pStartNode);
const SwEndNode* pEnd = pStartNode->EndOfSectionNode();
@@ -903,6 +976,7 @@ void SwXText::setString(const OUString& aString) throw( uno::RuntimeException )
GetDoc()->EndUndo(UNDO_END, NULL);
}
+//FIXME why is CheckForOwnMember duplicated in some insert methods?
// Description: Checks if pRange/pCursor are member of the same text interface.
// Only one of the pointers has to be set!
sal_Bool SwXText::CheckForOwnMember(
@@ -1361,7 +1435,8 @@ uno::Reference< text::XTextRange > SwXText::appendTextPortion(
if(rText.getLength())
{
xub_StrLen nContentPos = pCursor->GetPoint()->nContent.GetIndex();
- SwUnoCursorHelper::DocInsertStringSplitCR( *pDoc, *pCursor, rText );
+ SwUnoCursorHelper::DocInsertStringSplitCR( *pDoc, *pCursor, rText,
+ false );
SwXTextCursor::SelectPam(*pCursor, sal_True);
pCursor->GetPoint()->nContent = nContentPos;
}