Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
e1323281
Kaydet (Commit)
e1323281
authored
Haz 01, 2015
tarafından
Bjoern Michaelsen
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
use UnoCursorPointer in ParagraphFrameEnumeration
Change-Id: I5fdf0bdd8609aa07c49b155cc75cade8bdb2c292
üst
4186d572
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
105 deletions
+72
-105
unoparaframeenum.hxx
sw/source/core/inc/unoparaframeenum.hxx
+21
-14
unoobj2.cxx
sw/source/core/unocore/unoobj2.cxx
+45
-85
unoportenum.cxx
sw/source/core/unocore/unoportenum.cxx
+6
-6
No files found.
sw/source/core/inc/unoparaframeenum.hxx
Dosyayı görüntüle @
e1323281
...
...
@@ -22,42 +22,49 @@
#include <deque>
#include <boost/shared_ptr.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/container/XEnumeration.hpp>
#include <com/sun/star/text/XTextContent.hpp>
#include <cppuhelper/implbase.hxx>
#include <calbck.hxx>
#include <unobaseclass.hxx>
class
SwDepend
;
class
SwNodeIndex
;
class
SwPaM
;
class
SwFrameFormat
;
struct
FrameDependSortListEntry
namespace
sw
{
struct
FrameClient
:
public
SwClient
{
FrameClient
(
SwModify
*
pModify
)
:
SwClient
(
pModify
)
{};
};
}
struct
FrameClientSortListEntry
{
sal_Int32
nIndex
;
sal_uInt32
nOrder
;
::
boost
::
shared_ptr
<
SwDepend
>
pFrameDepend
;
std
::
shared_ptr
<
sw
::
FrameClient
>
pFrameClient
;
Frame
Depend
SortListEntry
(
sal_Int32
const
i_nIndex
,
sal_uInt32
const
i_nOrder
,
SwDepend
*
const
i_pDepend
)
:
nIndex
(
i_nIndex
),
nOrder
(
i_nOrder
),
pFrame
Depend
(
i_pDepend
)
{
}
Frame
Client
SortListEntry
(
sal_Int32
const
i_nIndex
,
sal_uInt32
const
i_nOrder
,
sw
::
FrameClient
*
const
i_pClient
)
:
nIndex
(
i_nIndex
),
nOrder
(
i_nOrder
),
pFrame
Client
(
i_pClient
)
{
}
};
typedef
::
std
::
deque
<
Frame
Depend
SortListEntry
>
Frame
Depend
SortList_t
;
typedef
::
std
::
deque
<
Frame
Client
SortListEntry
>
Frame
Client
SortList_t
;
typedef
::
std
::
deque
<
::
boost
::
shared_ptr
<
SwDepend
>
>
Frame
Depend
List_t
;
typedef
::
std
::
deque
<
std
::
shared_ptr
<
sw
::
FrameClient
>
>
Frame
Client
List_t
;
// #i28701# - adjust 4th parameter
void
CollectFrameAtNode
(
SwClient
&
rClnt
,
const
SwNodeIndex
&
rIdx
,
Frame
DependSortList_t
&
rFrames
,
const
bool
_
bAtCharAnchoredObjs
);
void
CollectFrameAtNode
(
const
SwNodeIndex
&
rIdx
,
Frame
ClientSortList_t
&
rFrames
,
const
bool
bAtCharAnchoredObjs
);
enum
ParaFrameMode
{
...
...
sw/source/core/unocore/unoobj2.cxx
Dosyayı görüntüle @
e1323281
...
...
@@ -155,20 +155,19 @@ void DeepCopyPaM(SwPaM const & rSource, SwPaM & rTarget)
}
// namespace sw
struct
Frame
Depend
SortListLess
struct
Frame
Client
SortListLess
{
bool
operator
()
(
Frame
Depend
SortListEntry
const
&
r1
,
Frame
Depend
SortListEntry
const
&
r2
)
const
bool
operator
()
(
Frame
Client
SortListEntry
const
&
r1
,
Frame
Client
SortListEntry
const
&
r2
)
const
{
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
,
FrameDependSortList_t
&
rFrames
,
const
bool
_bAtCharAnchoredObjs
)
void
CollectFrameAtNode
(
const
SwNodeIndex
&
rIdx
,
FrameClientSortList_t
&
rFrames
,
const
bool
bAtCharAnchoredObjs
)
{
// _bAtCharAnchoredObjs:
// <true>: at-character anchored objects are collected
...
...
@@ -177,7 +176,7 @@ void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx,
// search all borders, images, and OLEs that are connected to the paragraph
SwDoc
*
pDoc
=
rIdx
.
GetNode
().
GetDoc
();
const
sal_uInt16
nChkType
=
static_cast
<
sal_uInt16
>
((
_
bAtCharAnchoredObjs
)
const
sal_uInt16
nChkType
=
static_cast
<
sal_uInt16
>
((
bAtCharAnchoredObjs
)
?
FLY_AT_CHAR
:
FLY_AT_PARA
);
const
SwContentFrm
*
pCFrm
;
const
SwContentNode
*
pCNd
;
...
...
@@ -201,14 +200,14 @@ void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx,
if
(
rFormat
.
GetAnchor
().
GetAnchorId
()
==
nChkType
)
{
// create SwDepend and insert into array
SwDepend
*
pNewDepend
=
new
SwDepend
(
&
rClnt
,
&
rFormat
);
sw
::
FrameClient
*
pNewClient
=
new
sw
::
FrameClient
(
&
rFormat
);
const
sal_Int32
idx
=
rFormat
.
GetAnchor
().
GetContentAnchor
()
->
nContent
.
GetIndex
();
sal_uInt32
nOrder
=
rFormat
.
GetAnchor
().
GetOrder
();
// OD 2004-05-07 #i28701# - sorting no longer needed,
// because list <SwSortedObjs> is already sorted.
Frame
DependSortListEntry
entry
(
idx
,
nOrder
,
pNewDepend
);
Frame
ClientSortListEntry
entry
(
idx
,
nOrder
,
pNewClient
);
rFrames
.
push_back
(
entry
);
}
}
...
...
@@ -227,18 +226,18 @@ void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx,
0
!=
(
pAnchorPos
=
rAnchor
.
GetContentAnchor
())
&&
pAnchorPos
->
nNode
==
rIdx
)
{
SwDepend
*
pNewDepend
=
new
SwDepend
(
&
rClnt
,
const_cast
<
SwFrameFormat
*>
(
pFormat
));
sw
::
FrameClient
*
pNewClient
=
new
sw
::
FrameClient
(
const_cast
<
SwFrameFormat
*>
(
pFormat
));
// OD 2004-05-07 #i28701# - determine insert position for
// sorted <rFrameArr>
const
sal_Int32
nIndex
=
pAnchorPos
->
nContent
.
GetIndex
();
sal_uInt32
nOrder
=
rAnchor
.
GetOrder
();
Frame
DependSortListEntry
entry
(
nIndex
,
nOrder
,
pNewDepend
);
Frame
ClientSortListEntry
entry
(
nIndex
,
nOrder
,
pNewClient
);
rFrames
.
push_back
(
entry
);
}
}
::
std
::
sort
(
rFrames
.
begin
(),
rFrames
.
end
(),
Frame
Depend
SortListLess
());
::
std
::
sort
(
rFrames
.
begin
(),
rFrames
.
end
(),
Frame
Client
SortListLess
());
}
}
...
...
@@ -1576,19 +1575,16 @@ void SwUnoCursorHelper::SetString(SwCursor & rCursor, const OUString& rString)
pDoc
->
GetIDocumentUndoRedo
().
EndUndo
(
UNDO_INSERT
,
NULL
);
}
class
SwXParaFrameEnumeration
::
Impl
:
public
SwClient
struct
SwXParaFrameEnumeration
::
Impl
{
public
:
// created by hasMoreElements
uno
::
Reference
<
text
::
XTextContent
>
m_xNextObject
;
Frame
Depend
List_t
m_Frames
;
::
s
td
::
shared_ptr
<
SwUnoCrsr
>
m_pUnoCursor
;
Frame
Client
List_t
m_Frames
;
::
s
w
::
UnoCursorPointer
m_pUnoCursor
;
explicit
Impl
(
SwPaM
const
&
rPaM
)
:
m_pUnoCursor
(
rPaM
.
GetDoc
()
->
CreateUnoCrsr
(
*
rPaM
.
GetPoint
(),
false
))
{
m_pUnoCursor
->
Add
(
this
);
if
(
rPaM
.
HasMark
())
{
GetCursor
()
->
SetMark
();
...
...
@@ -1596,60 +1592,29 @@ public:
}
}
virtual
~
Impl
()
{
if
(
m_pUnoCursor
)
m_pUnoCursor
->
Remove
(
this
);
// Impl owns the cursor; delete it here: SolarMutex is locked
}
SwUnoCrsr
*
GetCursor
()
{
return
static_cast
<
SwUnoCrsr
*>
(
GetRegisteredIn
());
}
protected
:
// SwClient
virtual
void
Modify
(
const
SfxPoolItem
*
pOld
,
const
SfxPoolItem
*
pNew
)
SAL_OVERRIDE
;
virtual
void
SwClientNotify
(
const
SwModify
&
rModify
,
const
SfxHint
&
rHint
)
SAL_OVERRIDE
;
};
struct
InvalidFrameDepend
{
bool
operator
()
(
::
boost
::
shared_ptr
<
SwDepend
>
const
&
rEntry
)
{
return
!
rEntry
->
GetRegisteredIn
();
}
};
void
SwXParaFrameEnumeration
::
Impl
::
Modify
(
const
SfxPoolItem
*
pOld
,
const
SfxPoolItem
*
pNew
)
{
ClientModify
(
this
,
pOld
,
pNew
);
if
(
!
GetRegisteredIn
())
{
m_Frames
.
clear
();
m_xNextObject
=
0
;
}
else
{
// check if any frame went away...
FrameDependList_t
::
iterator
const
iter
=
::
std
::
remove_if
(
m_Frames
.
begin
(),
m_Frames
.
end
(),
InvalidFrameDepend
());
m_Frames
.
erase
(
iter
,
m_Frames
.
end
());
}
}
void
SwXParaFrameEnumeration
::
Impl
::
SwClientNotify
(
const
SwModify
&
rModify
,
const
SfxHint
&
rHint
)
{
SwClient
::
SwClientNotify
(
rModify
,
rHint
);
if
(
m_pUnoCursor
&&
typeid
(
rHint
)
==
typeid
(
sw
::
DocDisposingHint
))
SwUnoCrsr
*
GetCursor
()
{
return
&
(
*
m_pUnoCursor
);
}
void
PurgeFrameClients
()
{
m_pUnoCursor
->
Remove
(
this
);
m_pUnoCursor
.
reset
();
if
(
!
m_pUnoCursor
)
{
m_Frames
.
clear
();
m_xNextObject
=
nullptr
;
}
else
{
// removing orphaned SwDepends
const
auto
iter
=
std
::
remove_if
(
m_Frames
.
begin
(),
m_Frames
.
end
(),
[]
(
std
::
shared_ptr
<
sw
::
FrameClient
>&
rEntry
)
->
bool
{
return
!
rEntry
->
GetRegisteredIn
();
});
m_Frames
.
erase
(
iter
,
m_Frames
.
end
());
}
}
}
}
;
static
bool
lcl_CreateNextObject
(
SwUnoCrsr
&
i_rUnoCrsr
,
uno
::
Reference
<
text
::
XTextContent
>
&
o_rNextObject
,
Frame
Depend
List_t
&
i_rFrames
)
Frame
Client
List_t
&
i_rFrames
)
{
if
(
!
i_rFrames
.
size
())
return
false
;
...
...
@@ -1700,8 +1665,7 @@ lcl_CreateNextObject(SwUnoCrsr& i_rUnoCrsr,
// Search for a FLYCNT text attribute at the cursor point and fill the frame
// into the array
static
void
lcl_FillFrame
(
SwClient
&
rEnum
,
SwUnoCrsr
&
rUnoCrsr
,
FrameDependList_t
&
rFrames
)
lcl_FillFrame
(
SwUnoCrsr
&
rUnoCrsr
,
FrameClientList_t
&
rFrames
)
{
// search for objects at the cursor - anchored at/as char
SwTextAttr
const
*
const
pTextAttr
=
(
rUnoCrsr
.
GetNode
().
IsTextNode
())
...
...
@@ -1712,8 +1676,8 @@ lcl_FillFrame(SwClient & rEnum, SwUnoCrsr& rUnoCrsr,
{
const
SwFormatFlyCnt
&
rFlyCnt
=
pTextAttr
->
GetFlyCnt
();
SwFrameFormat
*
const
pFrameFormat
=
rFlyCnt
.
GetFrameFormat
();
SwDepend
*
const
pNewDepend
=
new
SwDepend
(
&
rEnum
,
pFrameFormat
);
rFrames
.
push_back
(
::
boost
::
shared_ptr
<
SwDepend
>
(
pNewDepend
)
);
sw
::
FrameClient
*
const
pNewClient
=
new
sw
::
FrameClient
(
pFrameFormat
);
rFrames
.
push_back
(
std
::
shared_ptr
<
sw
::
FrameClient
>
(
pNewClient
)
);
}
}
...
...
@@ -1724,18 +1688,18 @@ SwXParaFrameEnumeration::SwXParaFrameEnumeration(
{
if
(
PARAFRAME_PORTION_PARAGRAPH
==
eParaFrameMode
)
{
Frame
Depend
SortList_t
frames
;
::
CollectFrameAtNode
(
*
m_pImpl
.
get
(),
rPaM
.
GetPoint
()
->
nNode
,
Frame
Client
SortList_t
frames
;
::
CollectFrameAtNode
(
rPaM
.
GetPoint
()
->
nNode
,
frames
,
false
);
::
std
::
transform
(
frames
.
begin
(),
frames
.
end
(),
::
std
::
back_inserter
(
m_pImpl
->
m_Frames
),
::
boost
::
bind
(
&
Frame
DependSortListEntry
::
pFrameDepend
,
_1
));
::
boost
::
bind
(
&
Frame
ClientSortListEntry
::
pFrameClient
,
_1
));
}
else
if
(
pFormat
)
{
// create SwDepend for frame and insert into array
SwDepend
*
const
pNewDepend
=
new
SwDepend
(
m_pImpl
.
get
(),
pFormat
);
m_pImpl
->
m_Frames
.
push_back
(
::
boost
::
shared_ptr
<
SwDepend
>
(
pNewDepend
));
sw
::
FrameClient
*
const
pNewClient
=
new
sw
::
FrameClient
(
pFormat
);
m_pImpl
->
m_Frames
.
push_back
(
std
::
shared_ptr
<
sw
::
FrameClient
>
(
pNewClient
));
}
else
if
((
PARAFRAME_PORTION_CHAR
==
eParaFrameMode
)
||
(
PARAFRAME_PORTION_TEXTRANGE
==
eParaFrameMode
))
...
...
@@ -1750,12 +1714,12 @@ SwXParaFrameEnumeration::SwXParaFrameEnumeration(
SwFrameFormat
*
const
pFrameFormat
=
const_cast
<
SwFrameFormat
*>
(
&
((
*
aIter
)
->
GetFormat
()));
// create SwDepend for frame and insert into array
SwDepend
*
const
pNewDepend
=
new
SwDepend
(
m_pImpl
.
get
(),
pFrameFormat
);
m_pImpl
->
m_Frames
.
push_back
(
::
boost
::
shared_ptr
<
SwDepend
>
(
pNewDepend
));
sw
::
FrameClient
*
const
pNewClient
=
new
sw
::
FrameClient
(
pFrameFormat
);
m_pImpl
->
m_Frames
.
push_back
(
std
::
shared_ptr
<
sw
::
FrameClient
>
(
pNewClient
));
}
}
lcl_FillFrame
(
*
m_pImpl
.
get
(),
*
m_pImpl
->
GetCursor
(),
m_pImpl
->
m_Frames
);
lcl_FillFrame
(
*
m_pImpl
->
GetCursor
(),
m_pImpl
->
m_Frames
);
}
}
...
...
@@ -1767,10 +1731,9 @@ sal_Bool SAL_CALL
SwXParaFrameEnumeration
::
hasMoreElements
()
throw
(
uno
::
RuntimeException
,
std
::
exception
)
{
SolarMutexGuard
aGuard
;
if
(
!
m_pImpl
->
GetCursor
())
throw
uno
::
RuntimeException
();
m_pImpl
->
PurgeFrameClients
();
return
m_pImpl
->
m_xNextObject
.
is
()
||
lcl_CreateNextObject
(
*
m_pImpl
->
GetCursor
(),
m_pImpl
->
m_xNextObject
,
m_pImpl
->
m_Frames
);
}
...
...
@@ -1780,12 +1743,9 @@ throw (container::NoSuchElementException,
lang
::
WrappedTargetException
,
uno
::
RuntimeException
,
std
::
exception
)
{
SolarMutexGuard
aGuard
;
if
(
!
m_pImpl
->
GetCursor
())
{
throw
uno
::
RuntimeException
();
}
m_pImpl
->
PurgeFrameClients
();
if
(
!
m_pImpl
->
m_xNextObject
.
is
()
&&
m_pImpl
->
m_Frames
.
size
())
{
lcl_CreateNextObject
(
*
m_pImpl
->
GetCursor
(),
...
...
sw/source/core/unocore/unoportenum.cxx
Dosyayı görüntüle @
e1323281
...
...
@@ -80,7 +80,7 @@ static void lcl_CreatePortions(
TextRangeList_t
&
i_rPortions
,
uno
::
Reference
<
text
::
XText
>
const
&
i_xParentText
,
SwUnoCrsr
*
pUnoCrsr
,
Frame
Depend
SortList_t
&
i_rFrames
,
Frame
Client
SortList_t
&
i_rFrames
,
const
sal_Int32
i_nStartPos
,
const
sal_Int32
i_nEndPos
);
namespace
...
...
@@ -371,8 +371,8 @@ SwXTextPortionEnumeration::SwXTextPortionEnumeration(
"start or end value invalid!"
);
// find all frames, graphics and OLEs that are bound AT character in para
Frame
Depend
SortList_t
frames
;
::
CollectFrameAtNode
(
*
this
,
m_pUnoCrsr
->
GetPoint
()
->
nNode
,
frames
,
true
);
Frame
Client
SortList_t
frames
;
::
CollectFrameAtNode
(
m_pUnoCrsr
->
GetPoint
()
->
nNode
,
frames
,
true
);
lcl_CreatePortions
(
m_Portions
,
xParentText
,
m_pUnoCrsr
.
get
(),
frames
,
nStart
,
nEnd
);
}
...
...
@@ -1187,7 +1187,7 @@ static sal_Int32 lcl_ExportFrames(
TextRangeList_t
&
rPortions
,
Reference
<
XText
>
const
&
i_xParent
,
SwUnoCrsr
*
const
i_pUnoCrsr
,
Frame
Depend
SortList_t
&
i_rFrames
,
Frame
Client
SortList_t
&
i_rFrames
,
sal_Int32
const
i_nCurrentIndex
)
{
// Ignore frames which are not exported, as we are exporting a selection
...
...
@@ -1200,7 +1200,7 @@ static sal_Int32 lcl_ExportFrames(
// do not check for i_nEnd here; this is done implicity by lcl_MoveCursor
{
const
SwModify
*
const
pFrame
=
i_rFrames
.
front
().
pFrame
Depend
->
GetRegisteredIn
();
i_rFrames
.
front
().
pFrame
Client
->
GetRegisteredIn
();
if
(
pFrame
)
// Frame could be disposed
{
SwXTextPortion
*
pPortion
=
new
SwXTextPortion
(
i_pUnoCrsr
,
i_xParent
,
...
...
@@ -1243,7 +1243,7 @@ static void lcl_CreatePortions(
TextRangeList_t
&
i_rPortions
,
uno
::
Reference
<
text
::
XText
>
const
&
i_xParentText
,
SwUnoCrsr
*
const
pUnoCrsr
,
Frame
Depend
SortList_t
&
i_rFrames
,
Frame
Client
SortList_t
&
i_rFrames
,
const
sal_Int32
i_nStartPos
,
const
sal_Int32
i_nEndPos
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment